You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to use Xception model for fine-tuning and came across this error.
How to reproduce this error?
In xception.py file, just change model.load_weights(weights_path) to model.load_weights(weights_path, by_name=True) and run. You will get the following traceback.
Traceback (most recent call last):
File "xception.py", line 227, in <module>
model = Xception(include_top=True, weights='imagenet')
File "xception.py", line 212, in Xception
model.load_weights(weights_path, by_name=True)
File "/home/anish/env/local/lib/python2.7/site-packages/Keras-1.1.1-py2.7.egg/keras/engine/topology.py", line 2498, in load_weights
self.load_weights_from_hdf5_group_by_name(f)
File "/home/anish/env/local/lib/python2.7/site-packages/Keras-1.1.1-py2.7.egg/keras/engine/topology.py", line 2633, in load_weights_from_hdf5_group_by_name
K.batch_set_value(weight_value_tuples)
File "/home/anish/env/local/lib/python2.7/site-packages/Keras-1.1.1-py2.7.egg/keras/backend/tensorflow_backend.py", line 990, in batch_set_value
assign_op = x.assign(assign_placeholder)
File "/home/anish/env/local/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 555, in assign
return state_ops.assign(self._variable, value, use_locking=use_locking)
File "/home/anish/env/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_state_ops.py", line 47, in assign
use_locking=use_locking, name=name)
File "/home/anish/env/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op
op_def=op_def)
File "/home/anish/env/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2261, in create_op
set_shapes_for_outputs(ret)
File "/home/anish/env/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1636, in set_shapes_for_outputs
shapes = shape_func(op)
File "/home/anish/env/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1570, in call_with_requiring
return call_cpp_shape_fn(op, require_shape_fn=True)
File "/home/anish/env/local/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 643, in call_cpp_shape_fn
raise ValueError(err.message)
ValueError: Dimension 0 in both shapes must be equal, but are 1 and 3 for 'Assign' (op: 'Assign') with input shapes: [1,1,64,128], [3,3,3,32].
Workaround:
base_model = Xception(include_top=True, weights='imagenet')
model = Model(input=base_model.input, output=<fine-tune model>)
The text was updated successfully, but these errors were encountered:
For me it is solved by setting K.set_image_data_format('channels_last'), since the problem was that the channel axis was mixed up. But it might not work for your case.
I was trying to use Xception model for fine-tuning and came across this error.
How to reproduce this error?
xception.py
file, just changemodel.load_weights(weights_path)
tomodel.load_weights(weights_path, by_name=True)
and run. You will get the following traceback.Workaround:
The text was updated successfully, but these errors were encountered: