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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dimension error EEGnet

Cerebrock opened this issue · comments

commented

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

It might have to do with the image_data_format, see

(2) 'image_data_format' = 'channels_first' in keras.json config

If you try changing it, does it help?

commented

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,)

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

commented

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!

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!