deep-learning-models
deep-learning-models copied to clipboard
ValueError: CorrMM images and kernel must have the same stack size while running the example script
Hi,
I have been trying to follow the example script of
model = ResNet50(weights='imagenet')
img_path = '/data/dsp_emerging/ugwz/elephants.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
preds = model.predict(x)
print('Predicted:', decode_predictions(preds))
However, I got the following error message of ValueError: CorrMM images and kernel must have the same stack size
. I did not change anything in the code. Keras is of version 2.0.3
and Theano is of version 0.9.0
The complete traceback is
Traceback (most recent call last):
File "example.py", line 15, in <module>
preds = model.predict(x)
File "/tmp/lib/python3.5/site-packages/keras/engine/training.py", line 1573, in predict
batch_size=batch_size, verbose=verbose)
File "/tmp/lib/python3.5/site-packages/keras/engine/training.py", line 1203, in _predict_loop
batch_outs = f(ins_batch)
File "/tmp/lib/python3.5/site-packages/keras/backend/theano_backend.py", line 1122, in __call__
return self.function(*inputs)
File "/tmp/lib/python3.5/site-packages/theano/compile/function_module.py", line 898, in __call__
storage_map=getattr(self.fn, 'storage_map', None))
File "/tmp/lib/python3.5/site-packages/theano/gof/link.py", line 325, in raise_with_op
reraise(exc_type, exc_value, exc_trace)
File "/tmp/lib/python3.5/site-packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/tmp/lib/python3.5/site-packages/theano/compile/function_module.py", line 884, in __call__
self.fn() if output_subset is None else\
ValueError: CorrMM images and kernel must have the same stack size
Apply node that caused the error: CorrMM{valid, (2, 2), (1, 1)}(InplaceDimShuffle{0,3,1,2}.0, Subtensor{::, ::, ::int64, ::int64}.0)
Toposort index: 444
Inputs types: [TensorType(float32, 4D), TensorType(float32, 4D)]
Inputs shapes: [(1, 3, 230, 230), (7, 7, 64, 3)]
Inputs strides: [(12, 4, 2760, 12), (4, 28, -588, -196)]
Inputs values: ['not shown', 'not shown']
Outputs clients: [[InplaceDimShuffle{0,2,3,1}(CorrMM{valid, (2, 2), (1, 1)}.0)]]
Backtrace when the node is created(use Theano flag traceback.limit=N to make it longer):
File "example.py", line 6, in <module>
model = ResNet50(weights='imagenet')
File "/home/DL-Phase2/keras-DLmodel/resnet50.py", line 208, in ResNet50
x = Conv2D(64, (7, 7), strides=(2, 2), name='conv1')(x)
File "/tmp/lib/python3.5/site-packages/keras/engine/topology.py", line 578, in __call__
output = self.call(inputs, **kwargs)
File "/tmp/lib/python3.5/site-packages/keras/layers/convolutional.py", line 164, in call
dilation_rate=self.dilation_rate)
File "/tmp/lib/python3.5/site-packages/keras/backend/theano_backend.py", line 1769, in conv2d
filter_dilation=dilation_rate)
Did you fix this ?