Skip to content Skip to sidebar Skip to footer

Error When Checking Target: Expected Dense_20 To Have Shape (none, 3) But Got Array With Shape (1200, 1)

With VGG 16 using Keras, I'm trying to run a three class classification problem and here is the code: import numpy as np from keras.preprocessing.image import ImageDataGenerator fr

Solution 1:

Your training output is shaped like (None, 1) --- Or (1200, 1), where there are 1200 samples, all samples with only one dimension (each sample is a number)

But your model ends with Dense(3), which will output things like (None, 3). That is: each sample has 3 numbers.

If you think your training data is correct, you must adjust your model.

A suggestion is add one more Dense(1) layer. With a "sigmoid" activation if the result is between 0 and 1, or a "tanh" if the result is between -1 and 1.

Always use model.summary() to check what dimensions your model have.

Post a Comment for "Error When Checking Target: Expected Dense_20 To Have Shape (none, 3) But Got Array With Shape (1200, 1)"