vlawhern / arl-eegmodels

This is the Army Research Laboratory (ARL) EEGModels Project: A Collection of Convolutional Neural Network (CNN) models for EEG signal classification, using Keras and Tensorflow
Other
1.17k stars 287 forks source link

Dimension error EEGnet #5

Closed Cerebrock closed 6 years ago

Cerebrock commented 6 years ago

InvalidArgumentError: Negative dimension size caused by subtracting 64 from 1 for 'depthwise_conv2d_1/depthwise' (op: 'DepthwiseConv2dNative') with input shapes: [?,1,64,4], [64,1,4,2]. :S

robintibor commented 6 years ago

It might have to do with the image_data_format, see https://github.com/vlawhern/arl-eegmodels/blob/4558da71f87ac14299ea131c230f950de38de5d9/EEGModels.py#L7 If you try changing it, does it help?

Cerebrock commented 6 years ago

I tried both reshaping the input and changing the order of the parameters in the conv layers. With the modification of the json file I get a new error. image

ValueError: Error when checking target: expected softmax to have shape (11,) but got array with shape (1,)

vlawhern commented 6 years ago

You need to do the one-hot encoding of the class labels for multi-class classification; i.e.: an 11-column matrix of 0's and 1's indicating the class membership. To do this easily you can use a function found inside of keras:

tf.keras.utils.to_categorical

Cerebrock commented 6 years ago

I was skipping the cell with the one-hot, its running now!!! :D. The issue at first was the change in the .json file, why not use TF default ordering? Thank you guys!

vlawhern commented 6 years ago

It was a habit back when I was using Keras with Theano, as Theano used NCHW (samples, channels, height, width) as default, whereas Tensorflow uses NHWC. I have a version of this code that checks for the users ordering and builds the model according to that but I haven't pushed it yet.

Let me know if there are any other issues!