Closed pszyu closed 7 years ago
what is your input size
Hi Chen, my input size is the original one - (3, 224, 224)
def main(): model = ResNetBuilder.build_resnet_18((3, 224, 224), 1000) model.compile(loss="categorical_crossentropy", optimizer="sgd") model.summary()
Do you have idea of what the problem is? Thank you! @DanlanChen
I think it is some problem for my Theano or Keras library. Even the following code:
model = Sequential()
model.add(Convolution2D(64, 3, 3, border_mode='same', input_shape=(3, 256, 256)))
gives model.output_shape as (None, 3, 256, 64), instead of (None, 64, 256, 256)
I found the cause of my error in case someone else also encounter the same problem. It is about the ordering of the input - somehow my system recognise my input as (3, 256) with 256 channels. The solution is from:
I tried the third one that "Modify the keras configuration file by changing 'tf' to 'th' in your ~/.keras/keras.json" and it works.
After running default main() function with nothing changed, I got the following error. So wondering whether anyone else got this error as well and how to revise it. self.subsample[1] = 0. Thank you! Using Theano backend.
Traceback (most recent call last): File "/Users/PaulYu/Documents/git/Deep Residual Networks/keras-resnet/resnet.py", line 163, in
main()
File "/Users/PaulYu/Documents/git/Deep Residual Networks/keras-resnet/resnet.py", line 157, in main
model = ResNetBuilder.build_resnet_18((3, 224, 224), 1000)
File "/Users/PaulYu/Documents/git/Deep Residual Networks/keras-resnet/resnet.py", line 137, in build_resnet_18
return ResNetBuilder.build(input_shape, num_outputs, basic_block, [2, 2, 2, 2])
File "/Users/PaulYu/Documents/git/Deep Residual Networks/keras-resnet/resnet.py", line 124, in build
block = _residual_block(block_fn, nb_filters=nb_filters, repetitions=r, is_first_layer=i == 0)(block)
File "/Users/PaulYu/Documents/git/Deep Residual Networks/keras-resnet/resnet.py", line 66, in f
input = block_function(nb_filters=nb_filters, init_subsample=init_subsample)(input)
File "/Users/PaulYu/Documents/git/Deep Residual Networks/keras-resnet/resnet.py", line 79, in f
return _shortcut(input, residual)
File "/Users/PaulYu/Documents/git/Deep Residual Networks/keras-resnet/resnet.py", line 54, in _shortcut
init="he_normal", border_mode="valid")(input)
File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 514, in call
self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 572, in add_inbound_node
Node.create_node(self, inbound_layers, node_indices, tensor_indices)
File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 152, in create_node
output_shapes = to_list(outbound_layer.get_output_shape_for(input_shapes[0]))
File "/Library/Python/2.7/site-packages/keras/layers/convolutional.py", line 453, in get_output_shape_for
self.border_mode, self.subsample[1])
File "/Library/Python/2.7/site-packages/keras/utils/np_utils.py", line 131, in conv_output_length
return (output_length + stride - 1) // stride
ZeroDivisionError: integer division or modulo by zero
Process finished with exit code 1