'Python tensorflow conv2d returning a 5D matrix
I'm working with EEG signals and trying to build a machine learning model with Tensorflow, of which I am a complete beginner. I have 135 examples of matrices of shape 18x1000 (18 channels with 1000 samples each). I have them stored in X_train, and I reshaped it to get a 4D matrix, which has a shape of (135, 18, 1000, 1). I'm building the model using the following code:
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Conv2D(20, kernel_size = (3,3), activation ='relu', input_shape = X_train.shape, strides=(1,1), padding = "same"))
model.add(tf.keras.layers.MaxPool2D(pool_size = (1, 4), strides = (1,4)))
model.compile(optimizer = 'adam', loss = 'binary_crossentropy', metrics = ['accuracy'])
history = model.fit(X_train, y_train, batch_size = 32, epochs = 25)
I'm getting the following error:
ValueError: Input 0 of layer max_pooling2d is incompatible with the layer: expected ndim=4, found ndim=5. Full shape received: (None, 135, 18, 1000, 20)
So I guess the Conv2D layer is giving me a 5D matrix output? What am I doing wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
