I'm trying to train this Convolutional Neural Network but can't figure out what the issue is with my last layer.
model = Sequential()
model.add(Conv1D(50, kernel_size=(1),
activation='relu',
input_dim=50))
model.add(Dense(32))
model.add(Dense(1))
model.summary()
model.compile(loss=keras.losses.mean_squared_error,
optimizer=keras.optimizers.adam())
model.fit(X_train, y_train,
batch_size=940,
epochs=10,
verbose=1,
validation_data=(X_test, y_test))
Model:
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv1d_26 (Conv1D) (None, None, 50) 2550
_________________________________________________________________
dense_38 (Dense) (None, None, 32) 1632
_________________________________________________________________
dense_39 (Dense) (None, None, 1) 33
=================================================================
Total params: 4,215.0
Trainable params: 4,215
Non-trainable params: 0.0
_________________________________________________________________
I always get the following error message:
ValueError: Error when checking model target: expected dense_39 to have 3 dimensions, but got array with shape (940, 1)
I suspect the issue is that for the last layer I got only one output node, so the output dimensions are reduced to two.