I'm migrating a project from Keras 1.x to 2.x.
In the code, a keras.backend.conv2d
operation that was running fine in 1.x now crashes in 2.x.
convs = K.conv2d(a, b, padding='valid', data_format='channels_first')
Input tensors shapes a
and b
are both (1024, 4, 1, 1)
and output tensor shape was (1024, 1024, 1, 1)
in 1.x.
With 2.x I'm getting the following error:
ValueError: CorrMM: impossible output shape
bottom shape: 1024 x 4 x 1 x 1
weights shape: 1 x 1 x 1024 x 4
top shape: 1024 x 1 x -1022 x -2
Apply node that caused the error: CorrMM{valid, (1, 1), (1, 1), 1 False}(Print{message='a', attrs=('__str__',), global_fn=<function DEBUG_printTensorShape at 0x00000272EF1FAD08>}.0, Subtensor{::, ::, ::int64, ::int64}.0)
Toposort index: 30
Inputs types: [TensorType(float32, (False, False, True, True)), TensorType(float32, (True, True, False, False))]
Inputs shapes: [(1024, 4, 1, 1), (1, 1, 1024, 4)]
I'm using Theano backend, and set channels_first
both in K.set_image_data_format
and conv2d
.