Error When Checking Target: Expected Softmax_1 To Have Shape (1,) But Got Array With Shape (2,)', Keras
I am using Keras for building Conv Net for the first time. My layers are as follows: layers = [ Conv2D(8,kernel_size=(4,4),padding='same',input_shape=( 200, 180,3),kernel_initializ
Solution 1:
The problem is that you are using sparse_categorical_crossentropy
as the loss function. This loss function is used when the given labels (i.e. Y_train
) are encoded as integers (i.e. 0, 1, 2, ...). However, If the labels are one-hot encoded, which seems to be the case in your code, you need to use categorical_crossentropy
as the loss function instead.
Post a Comment for "Error When Checking Target: Expected Softmax_1 To Have Shape (1,) But Got Array With Shape (2,)', Keras"