Why does CNN gives negative dimension ValueError?

Viewed 36

My model is the following:

Model: "sequential_24"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
embedding_17 (Embedding)     (None, 100, 100)          500100    
_________________________________________________________________
conv1d_14 (Conv1D)           (None, 96, 128)           64128     
_________________________________________________________________
global_max_pooling1d_13 (Glo (None, 128)               0         
_________________________________________________________________
dense_37 (Dense)             (None, 10)                1290      
_________________________________________________________________
dense_38 (Dense)             (None, 1)                 11        
=================================================================

When fitting the model

history = model.fit(train_df.sentence, train_df.label, epochs=10, validation_data=(val_df.sentence, val_df.label))

I get the following error

Epoch 1/10

WARNING:tensorflow:Model was constructed with shape (None, 100) for input KerasTensor(type_spec=TensorSpec(shape=(None, 100), dtype=tf.float32, name='embedding_14_input'), name='embedding_14_input', description="created by layer 'embedding_14_input'"), but it was called on an input with incompatible shape (None, 1)

ValueError: Negative dimension size caused by subtracting 5 from 1 for '{{node sequential_21/conv1d_11/conv1d}} = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], explicit_paddings=[], padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true](sequential_21/conv1d_11/conv1d/ExpandDims, sequential_21/conv1d_11/conv1d/ExpandDims_1)' with input shapes: [?,1,1,100], [1,5,100,128].
0 Answers
Related