3D Convolutional Neural Network input shape 3D Convolutional Neural Network input shape numpy numpy

3D Convolutional Neural Network input shape


I think that the problem is that you are setting the input shape in Theano ordering but you are using Keras with Tensorflow backend and Tensorflow img ordering. In addition the y_train array has to be converted to categorical labels.

Updated code:

from keras.utils import np_utilsfrom keras import backend as Kif K.image_dim_ordering() == 'th':    X_train = X_train.reshape(X_train.shape[0], 1, img_rows, img_cols, img_depth)    input_shape = (1, img_rows, img_cols, img_depth)else:    X_train = X_train.reshape(X_train.shape[0], img_rows, img_cols, img_depth, 1)    input_shape = (img_rows, img_cols, img_depth, 1)Y_train = np_utils.to_categorical(Y_train, nb_classes)

Adding this lines should fix it.