4
votes

I am using keras MLP network for binary classification of 3-D word vector input_shape=(None,24,73). I have used two dense layers dense_1 and dense_2. At dense_2 I'm getting an error which I've not been able to solve.

This is my model summary.

Layer (type)                 Output Shape              Param #   
=================================================================
dense_1 (Dense)              (None, 8, 90)             6660      
_________________________________________________________________
dense_2 (Dense)              (None, 8, 1)              91        
=================================================================
Total params: 6,751
Trainable params: 6,751
Non-trainable params: 0

ValueError: Error when checking target: expected dense_2 to have 3 dimensions, but got array with shape (22, 1)

1
show us the data shape of your target (y). From what I can see here the error is complaining that your target and the output of the model dont have the same shapeparsethis

1 Answers

5
votes

Since you have a binary_classification task your last layer should look something like this

model.add(Dense(1, activation='sigmoid'))

Right now you model is out puting 3D array which don't match the shape of your target (2D)