I have to train a cnn using as loss function mse. I normalized the labels between 0-1 but when I train I get

expected dense_2 to have shape (1,) but got array with shape (7,)

The last layer is x = Dense(1, activation='linear')(x)

and when I compile and train:

model.compile(loss=keras.losses.mean_squared_error, optimizer=Adam(lr=0.001),metrics=['mse'])


model_details=model.fit(X_train, Y_train)

1 Answers

0
fpi On Best Solutions

I resized the Y_train matrix to 1D vector: each component of the vector is the label to the respective image.