I am facing this error in Keras 2. How can I resolve it? I have imported
from keras.layers import Input, merge
[...]
up1 = merge([UpSampling2D(size=(2, 2))(conv3), conv2], mode='concat', concat_axis=1)
/usr/local/python/3.5.2-gcc4/externalmodules/lib/python3.5/site-packages/keras/legacy/layers.py:456: UserWarning: The `Merge` layer is deprecated and will be removed after 08/2017. Use instead layers from `keras.layers.merge`, e.g. `add`, `concatenate`, etc.
name=name)
Traceback (most recent call last):
File "./src/retinaNN_training.py", line 171, in <module>
model = get_unet(n_ch, patch_height, patch_width) #the U-net model
File "./src/retinaNN_training.py", line 53, in get_unet
up1 = merge([UpSampling2D(size=(2, 2))(conv3), conv2], mode='concat', concat_axis=1)
File "/usr/local/python/3.5.2-gcc4/externalmodules/lib/python3.5/site-packages/keras/legacy/layers.py", line 456, in merge
name=name)
File "/usr/local/python/3.5.2-gcc4/externalmodules/lib/python3.5/site-packages/keras/legacy/layers.py", line 107, in __init__
node_indices, tensor_indices)
File "/usr/local/python/3.5.2-gcc4/externalmodules/lib/python3.5/site-packages/keras/legacy/layers.py", line 187, 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, 2, 24, 128), (None, 1, 24, 64)]
How can I convert the merge function to be readable on Keras 2.x.x.? Thanks
Layer shapes: [(None, 2, 24, 128), (None, 1, 24, 64)]
you have to adjust the shapes of what you're passing to the merge. It's simply impossible to merge those. You "probably" should have both ending in 128 or both ending in 64. – Daniel MöllerKeras 1
andKeras 2
. An I do not know how to solve this. – S.EB