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

Can't not run the code

LinzzMichael opened this issue · comments

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.

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

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

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

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

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