Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Conv3D in MXNet: error with Tensor shape #240

Open
3 tasks done
sdbonte opened this issue Jul 12, 2019 · 0 comments
Open
3 tasks done

Conv3D in MXNet: error with Tensor shape #240

sdbonte opened this issue Jul 12, 2019 · 0 comments
Labels

Comments

@sdbonte
Copy link

sdbonte commented Jul 12, 2019

  • 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()
@roywei roywei added the bug label Aug 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants