-
Notifications
You must be signed in to change notification settings - Fork 61
Conv3D in MXNet: error with Tensor shape #240
Description
-
Check that you are up-to-date with the master branch of Keras. You can update with:
pip install git+git://github.com/keras-team/keras.git --upgrade --no-deps
-
Check that your version of TensorFlow is up-to-date. The installation instructions can be found here.
-
Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).
I posted this question on StackOverflow where it was suggested to open an issue here.
I implemented a CNN with inception blocks in Keras which runs fine with TensorFlow Backend, but when changing to MXNet, an error occurs when calculating the filter2
in the function TestNet
:
mxnet.base.MXNetError: Error in operator concat0: [11:50:11] C:\Jenkins\workspace\mxnet-tag\mxnet\src\operator\nn\concat.cc:66: Check failed: shape_assign(&(*in_shape)[i], dshape) Incompatible input shape: expected [0,0,64,64,64], got [0,16,64,65,65]
So running the SimpleInceptionBlock
function a first time runs fine, but when running it again on the output of this function creates an error. Any ideas how this can be solved?
from keras.models import *
from keras.layers import *
from keras.optimizers import *
def SimpleInceptionBlock(input, num_kernels, kernel_init='he_normal', padding='same', bn_axis=1):
tower1 = Conv3D(num_kernels, 1, padding=padding, kernel_initializer=kernel_init)(input)
tower1 = BatchNormalization()(tower1)
tower1 = ELU()(tower1)
tower2 = MaxPooling3D(pool_size=(2, 2, 2), strides=(1, 1, 1), padding=padding)(input)
tower2 = Conv3D(num_kernels, 1, padding=padding, kernel_initializer=kernel_init)(tower2)
tower2 = BatchNormalization()(tower2)
tower2 = ELU()(tower2)
output = concatenate([tower1, tower2], axis=bn_axis)
return output
def TestNet(input_size=(1,64,64,64), num_class=7):
bn_axis = 1
img_input = Input(shape=input_size)
filter1 = SimpleInceptionBlock(img_input, 16)
# this runs fine, filter1.shape = (None, 32, 64, 64, 64)
filter2 = SimpleInceptionBlock(filter1, 16)
output = Conv3D(num_class, (1, 1, 1), activation='softmax', kernel_initializer = kernel_init, padding='same', kernel_regularizer=l2(1e-4))(filter2)
model = Model(input=img_input, output=output)
return model
model = TestNet()