I have the following problem: I have a script in Keras which works like a charm. I would like to convert this script to MXNet now. The CNN in Keras looks like this:
model=Sequential()
model.add(Convolution2D(128, (3, 3), padding='same', activation='relu', name='block1_conv1', input_shape=(80,120,3)))
model.add(MaxPooling2D((2, 2), strides=(2, 2)))
model.add(Convolution2D(256, (3, 3), padding='same', activation='relu', name='block2_conv1'))
model.add(MaxPooling2D((2, 2), strides=(2, 2)))
model.add(Flatten())
model.add(Dense(2, activation = 'softmax', name='final_fully_connected'))
I thought the conversion to MXNet couldn't be that difficult, I looked at the corresponding documentation and transferred the parameters to my best knowledge.
model=gluon.nn.Sequential()
with model.name_scope():
model.add(gluon.nn.Conv2D(channels=128, kernel_size=(3, 3), activation='relu'))
model.add(gluon.nn.MaxPool2D(pool_size=(2, 2), strides=(2, 2)))
model.add(gluon.nn.Conv2D(channels=256, kernel_size=(3, 3), activation='relu'))
model.add(gluon.nn.MaxPool2D(pool_size=(2, 2), strides=(2, 2)))
# The Flatten layer collapses all axis, except the first one, into one axis.
model.add(gluon.nn.Flatten())
model.add(gluon.nn.Dense(2, activation='relu'))
But if I try to train the model now, I get the following error:
"MXNetError: [17:01:34] C:\ci\libmxnet_1533399150922\work\src\operator\nn\pooling.cc:145: Check failed: param.kernel[1] <= dshape[3] + 2 * param.pad[1] kernel size (2) exceeds input (1 padded to 1)"
I think it has something to do with the dimensions of the kernel and the MaxPooling2D layer, but I don't understand the error because I thought I was actually building the same network as in Keras.
For completeness: My input variable X has the dimensions (80, 120, 3).
I would really appreciate the help of some Keras/MXNet pros.