Closed pszyu closed 7 years ago
I, too, am getting this error. Still trying to work around it.
looking into 2.
Did you change input size by any chance? I am not able to repro this issue.
For me the shape of my input is 320 x 160 (3 channels).
Same stack trace, but with:
Exception: Only layers of same output shape can be merged using sum mode. Layer shapes: [(None, 1, 80, 64), (None, 1, 80, 256)]
The last avg pooling layer needs to be 10, 5 instead of 7, 7. By the time input reaches block 4, it has volume 2048 * 10 * 5
I updated the code to provide a factory class to assist building resnets. Now you can simply do: model = ResNetBuilder.build_resnet_50((3, 320, 160), 1000)
I have a two questions to consult.
I am trying to find code to do experiments on residual deep networks. I am wondering whether this code is used to train a residual deep network or is used only for creating model visualisation? If I can use it to train a model, how should I input my training data?
I used both Theano and TensorFlow as backend of Keras to run the original code, but it gives me same error (using Theano as an example): Using Theano backend. Traceback (most recent call last): File "resnet.py", line 147, in
main()
File "resnet.py", line 127, in main
model = resnet()
File "resnet.py", line 110, in resnet
block1 = _residual_block(block_fn, nb_filters=64, repetations=3, is_first_layer=True)(pool1)
File "resnet.py", line 94, in f
input = block_function(nb_filters=nb_filters, init_subsample=init_subsample)(input)
File "resnet.py", line 51, in f
return _shortcut(input, residual)
File "resnet.py", line 84, in _shortcut
return merge([shortcut, residual], mode="sum")
File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 1528, in merge
name=name)
File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 1186, in init
node_indices, tensor_indices)
File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 1221, in _arguments_validation
'Layer shapes: %s' % input_shapes)
Exception: Only layers of same output shape can be merged using sum mode. Layer shapes: [(None, 1, 56, 64), (None, 1, 56, 256)]
It seems that the code already tried to match the input size, but the error is still there. I am wondering whether anyone has also met this problem. I used Python 2.7, Keras 1.1.1, tensorflow-0.11.0, and Theano 0.8.2.
Thank you!