Skip to content Skip to sidebar Skip to footer

Valueerror: Error When Checking Input: Expected Dense_1_input To Have Shape (180,) But Got Array With Shape (1,)

My learning model is as follows (using Keras). model = Sequential() model.add(Dense(100, activation='relu', input_shape = (X_train.shape[0],))) model.add(Dense(500, activation='rel

Solution 1:

In your case, the input_shape defined in the first layer, should be (1,):

X_train.shape[0] is the number of samples, each sample has for shape (1,).

Moreover, your call to the fit function won't work as your output has for shape (2,) (Dense(2)) whereas the shape of each target sample is (1,) (you have 180 of those).

Solution 2:

As @Thomas Schillaci wrote, the problem is that if you write X_train.shape[0] you are taking into account the number of samples of your dataset. But in that line the code want to know how many features you have, so you have to change in X_train.shape[1] in order to have the n° of input. How many labels do you have?

Post a Comment for "Valueerror: Error When Checking Input: Expected Dense_1_input To Have Shape (180,) But Got Array With Shape (1,)"