-
Notifications
You must be signed in to change notification settings - Fork 19.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Input 0 of layer "dense_2" is incompatible with the layer: expected axis -1 of input shape to have value 16384, but received input with shape (None, 65536) #19367
Comments
@sachinprasadhs help me out |
Could you please provide reproducible code in a colab Gist to understand more on the issue. Thanks! |
You are restricting the from keras.layers import Dense, Conv2D, MaxPool2D, Flatten
from keras.models import Sequential
model = Sequential()
model.add(Conv2D(filters=32, kernel_size=3, padding="same", activation="relu",input_shape=[256,256,3]))
model.add(Conv2D(filters=32, kernel_size=3, padding="same", activation="relu"))
model.add(MaxPool2D(pool_size=2,strides=2))
model.add(Conv2D(filters=64, kernel_size=3, padding="same", activation="relu"))
model.add(Conv2D(filters=64, kernel_size=3, padding="same", activation="relu"))
model.add(MaxPool2D(pool_size=2,strides=2))
model.add(Conv2D(filters=128, kernel_size=3, padding="same", activation="relu"))
model.add(Conv2D(filters=128, kernel_size=3, padding="same", activation="relu"))
model.add(MaxPool2D(pool_size=2,strides=2))
model.add(Conv2D(filters=256, kernel_size=3, padding="same", activation="relu"))
model.add(Conv2D(filters=256, kernel_size=3, padding="same", activation="relu"))
model.add(MaxPool2D(pool_size=2,strides=2))
model.add(Flatten())
model.add(Dense(units = 1024, activation="relu"))
model.add(Dense(units = 1024, activation="relu"))
model.add(Dense(units = 38, activation="softmax"))
model.compile(optimizer = "adam", loss ='categorical_crossentropy', metrics=['accuracy']) |
ValueError Traceback (most recent call last) File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/keras/src/utils/traceback_utils.py:123, in filter_traceback..error_handler(*args, **kwargs) File /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/keras/src/backend/tensorflow/nn.py:546, in categorical_crossentropy(target, output, from_logits, axis) ValueError: Arguments still i get the error dude! :( |
It is basically the number of classes you are using, if the data is a binary classification then you need to change the output layer to something like |
Thank you so much bro solved |
Hey there!! This is the issue I get
ValueError: Exception encountered when calling Sequential.call().
Input 0 of layer "dense_2" is incompatible with the layer: expected axis -1 of input shape to have value 16384, but received input with shape (None, 65536)
Arguments received by Sequential.call():
• inputs=tf.Tensor(shape=(None, 256, 256, 3), dtype=float32)
• training=True
• mask=None
code is here!
history = model.fit(x=training_set,validation_data=validation_set, epochs=10)
The text was updated successfully, but these errors were encountered: