Home>

I want to do deep learning, but I don't know how to solve the error.

ValueError: Error when checking target: expected dense_4 to have shape (1,) but got array with shape (2,)
Corresponding source code

Dense related part

model = Sequential ([Dense (40, activation = "relu", input_dim = 66), Dropout (0.2),
                    Dense (20, activation = "relu"), Dropout (0.2),
                    Dense (10, activation = "relu"), Dropout (0.2),
                    Dense (4, activation = "softmax")])


model.compile (optimizer = "adam", loss = "sparse_categorical_crossentropy"
              , metrics = ["accuracy"])



hist = model.fit (X_train, y_train, batch_size = 47, epochs = 100, verbose = 2)


model.summary ()
comment

What exactly does shape mean?