tdeboissiere / DeepLearningImplementations

Implementation of recent Deep Learning papers
MIT License
1.81k stars 650 forks source link

concat" mode can only merge layers with matching output shapes #3

Closed SnowRipple closed 7 years ago

SnowRipple commented 7 years ago

Hi Thibault,

Congrats on reimplementing DenseNets in Keras!

I am trying to run your code locally (run_cifar10 in densenet) using Theano and I am getting an error:

Using Theano backend. Traceback (most recent call last): File "/home/piotr/workspace/DeepLearningImplementations/DenseNet/run_cifar10.py", line 43, in weight_decay=weight_decay) File "/home/piotr/workspace/DeepLearningImplementations/DenseNet/densenet.py", line 99, in DenseNet weight_decay=weight_decay) File "/home/piotr/workspace/DeepLearningImplementations/DenseNet/densenet.py", line 58, in denseblock x = merge(list_feat, mode='concat', concat_axis=1) File "/usr/local/lib/python2.7/dist-packages/Keras-1.1.0-py2.7.egg/keras/engine/topology.py", line 1528, in merge name=name) File "/usr/local/lib/python2.7/dist-packages/Keras-1.1.0-py2.7.egg/keras/engine/topology.py", line 1186, in init node_indices, tensor_indices) File "/usr/local/lib/python2.7/dist-packages/Keras-1.1.0-py2.7.egg/keras/engine/topology.py", line 1253, in _arguments_validation 'Layer shapes: %s' % (input_shapes)) Exception: "concat" mode can only merge layers with matching output shapes except for the concat axis. Layer shapes: [(None, 3, 32, 16), (None, 3, 32, 12)]

Any idea why it is crashing?

Many Thanks!

SnowRipple commented 7 years ago

@tdeboissiere Just wanted to say that the same error persists when using tensorflow backend

Sandv commented 7 years ago

Hi, tdeboissiere, thank you very much for your contributions! I have the same issue as SnowRipple (using Tensorflow backend), any ideas how to fix it?

Thank you very much!

tdeboissiere commented 7 years ago

The only way I was able to reproduce your issue was by modifying the keras.json file in the ~/.keras folder.

With: { "image_dim_ordering": "th", "epsilon": 1e-07, "floatx": "float32", "backend": "theano" }

it compiles without any issue

With: { "image_dim_ordering": "tf", "epsilon": 1e-07, "floatx": "float32", "backend": "theano" }

I get the same error as you.

I'm going to modify the code to avoid the hassle of figuring which config to choose.

Edit:

Done, tell me if that fixed it.

Sandv commented 7 years ago

Just tried it out. Model builds without problems! Thank you very much! This is the one gripe I have with Keras - it is not fully independent of the backend...

Thank you very much for your time. Veit

tdeboissiere commented 7 years ago

Cool !

Closing