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.14k stars 284 forks source link

Can't not run the code #12

Closed LinzzMichael closed 5 years ago

LinzzMichael commented 5 years ago

when I run the code, I got the error "Negative dimension size caused by subtracting 64 from 1 for 'depthwise_conv2d/depthwise' (op: 'DepthwiseConv2dNative') with input shapes: [?,1,64,8], [64,1,8,2]." and I found it's not caused by my dataset, it's caused by the DepthwiseConv2D operate in line 139.

vlawhern commented 5 years ago

You'll need to change the Keras variable "image_data_format" to "channels_first". You can do this in two ways:

  1. Change it in your keras.json configuration file (https://keras.io/backend/#switching-from-one-backend-to-another)

  2. Include the following two lines at the top of your code

from tensorflow.keras import backend as K
K.set_image_data_format('channels_first')
LinzzMichael commented 5 years ago

Thank you for your answer, it' my mistake not see your introduction, I had run the code successfully now.

vlawhern commented 5 years ago

Good to hear. Let me know if there are any other issues.

XiaoYu0207 commented 4 years ago

Hi, good to hear that you have fixed the problem. However, I encountered the same problem, can you share your method about fixing it?

vlawhern commented 4 years ago

The solution above should still work. Put these two lines at the top of your code.


from tensorflow.keras import backend as K
K.set_image_data_format('channels_first')