orobix / retina-unet

Retina blood vessel segmentation with a convolutional neural network
1.28k stars 468 forks source link

ValueError: "concat" mode can only merge layers with matching output shapes except for the concat axis. Layer shapes: [(None, 0, 24, 128), (None, 0, 24, 64)] #31

Closed baodingge closed 7 years ago

baodingge commented 7 years ago

up1 = merge([UpSampling2D(size=(2, 2))(conv3), conv2], mode='concat', concat_axis=1) File "/usr/local/lib/python2.7/dist-packages/keras/legacy/layers.py", line 460, in merge name=name) File "/usr/local/lib/python2.7/dist-packages/keras/legacy/layers.py", line 111, in init node_indices, tensor_indices) File "/usr/local/lib/python2.7/dist-packages/keras/legacy/layers.py", line 191, in _arguments_validation 'Layer shapes: %s' % (input_shapes)) ValueError: "concat" mode can only merge layers with matching output shapes except for the concat axis. Layer shapes: [(None, 0, 24, 128), (None, 0, 24, 64)]

my keras version is 2.0.4 and i also change the keras.json file. I try my best, and can not deal with this problem

baodingge commented 7 years ago

I have solved this problem, my keras version is 2.0.4 . One important thing is thar conv2d has the attribute data_format, we should explicitly specify data_format='channels_first', because we are using theano.data format is [channel, height, width].

dcorti commented 7 years ago

Yes, the code was developed with keras 1.1, i'm working to upgrade to keras 2.

dcorti commented 7 years ago

Sorry, did not have time to fix it. However, thanks to @GlastonburyC now the code is compatible with keras 2

gemfield commented 7 years ago

You can ref https://zhuanlan.zhihu.com/p/29673286 for the solution. May be you also need Google translate.