I am getting the following error while using a data generator for my Keras model. There are many articles on StackOverflow on this specific error, but I think none of them apply to my case (or at least I couldn't translate the root cause to this one)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot batch tensors with different shapes in component 0. First element had shape [10] and element 21 had shape [7]Everything works fine when I use a batch size of 1, but things start breaking for a batch size > 1. It will be nice to understand what exactly is going on here?
Following is a simple Keras model to duplicate the issue
def fetch_model():
new_model = Sequential()
new_model.add(BatchNormalization(input_shape=(10, 128))) # The input shape excludes batch
new_model.add(Flatten())
new_model.add(Dense(2048, activation="relu"))
new_model.add(Dense(audioset_label_count, activation="sigmoid"))
new_model.compile("adam", loss="binary_crossentropy", metrics=["accuracy"])
return new_modeland I am training the model on AudioSet data, and I have added a sample of that to https://github.com/i2infinity/python-demo
For reproducing this issue, please run python train.py on https://github.com/i2infinity/python-demo.git
--
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+u...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/6ac3ecf5-b826-437d-ac39-7142a9a13425%40tensorflow.org.