I am trying to implement a 1 channel CNN by slightly changing this article: this article. The problem is that I am new to keras and deep learning and I don't know this far why I am getting this error:
ValueError: Negative dimension size caused by subtracting 100 from 1 for 'conv2d_1/convolution' (op: 'Conv2D') with input shapes: [?,1,70,100], [100,100,100,64]
Obviously, it's a mismatch in the dimensions.
I am using this code code:
from keras.layers import Embedding
from keras.layers import Conv2D
from keras.models import Sequential
from keras.layers import MaxPooling2D
from keras.layers import Reshape
import pdb
Vocab_Size=11123
MAX_SEQUENCE_LENGTH=70
EMBED_DIM=100
model = Sequential()
embed1=Embedding(Vocab_Size+1,EMBED_DIM,input_length=MAX_SEQUENCE_LENGTH,input_shape=(MAX_SEQUENCE_LENGTH,EMBED_DIM,1))
nb_labels=6
model = Sequential()
model.add(embed1)
model.add(Reshape((1,MAX_SEQUENCE_LENGTH, EMBED_DIM)))
model.add(Conv2D(64, strides=5, kernel_size=EMBED_DIM, activation="relu", padding='valid'))
model.add(MaxPooling2D((MAX_SEQUENCE_LENGTH-5+1,1)))
model.add(Flatten())
model.add(Dense(256, activation="relu"))
model.add(Dropout(0.3))
model.add(Dense(len(nb_labels), activation="softmax"))
model.compile(loss='categorical_crossentropy',
optimizer='rmsprop',
metrics=['acc'])
Edit1: I updated as mentionned by Media padding to same. Now I have another problem for the next layer:
ValueError: Negative dimension size caused by subtracting 66 from 1 for 'max_pooling2d_1/MaxPool' (op: 'MaxPool') with input shapes: [?,1,14,64].