ValueError: Shapes (1, 1, 1024, 75) and (255, 1024, 1, 1) are incompatible
See original GitHub issueTraceback (most recent call last):
File "test.py", line 58, in <module>
yolo4_model.load_weights(model_path)
File "/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py", line 492, in load_wrapper
return load_function(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/keras/engine/network.py", line 1230, in load_weights
f, self.layers, reshape=reshape)
File "/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py", line 1237, in load_weights_from_hdf5_group
K.batch_set_value(weight_value_tuples)
File "/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py", line 2960, in batch_set_value
tf_keras_backend.batch_set_value(tuples)
File "/home/mayur/.local/lib/python3.6/site-packages/tensorflow_core/python/keras/backend.py", line 3323, in batch_set_value
x.assign(np.asarray(value, dtype=dtype(x)))
File "/home/mayur/.local/lib/python3.6/site-packages/tensorflow_core/python/ops/resource_variable_ops.py", line 819, in assign
self._shape.assert_is_compatible_with(value_tensor.shape)
File "/home/mayur/.local/lib/python3.6/site-packages/tensorflow_core/python/framework/tensor_shape.py", line 1110, in assert_is_compatible_with
raise ValueError("Shapes %s and %s are incompatible" % (self, other))
ValueError: Shapes (1, 1, 1024, 75) and (255, 1024, 1, 1) are incompatible
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
ValueError: Shapes (None, 1) and (None, 50) are incompatible
I was training a CNN model (transfer learning). While compiling, I got the following error. ValueError: Shapes (None, 1) and (None, 50) are...
Read more >ValueError: Shapes (None, 1) and (None, 3) are incompatible
The first problem is with the LSTM input_shape. input_shape = (20,85,1) . From the doc: https://keras.io/layers/recurrent/.
Read more >Tensorflow - I don't get the right shapes - `ValueError
The error occurs because of the x_test shape. In your code, you set it actually to x_train. [x_test = x_train / 255.0] Furthermore,...
Read more >ValueError: Shapes (1, 1, 512, 12) and (75, 512 ... - CSDN博客
ValueError : Shapes (1, 1, 512, 12) and (75, 512, 1, 1) are incompatible ... 出现上述错误可能是1、train.py(训练的py文件)里面的num_classes没改。 2 ...
Read more >Could you help me solve this error - TensorFlow Forum
ValueError : Shapes (None, 1) and (None, 10) are incompatible I use anaconda / spyder to test the tensorflow learning categorise the image ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

that means that some model’s layers have different shape then the weights you load. This is surely because you created the model with another number of classes (not 80), so the conv_110 layer has (1, 1, 1024, 75) weights’ shape instead of (1, 1, 1024, 255) that the model with weights you load was. So, you need to use
yolo4_model.load_weights(model_path, by_name=True, skip_mismatch=True)to load only coinciding layer’s weights without errors. In particular, in this case all except the last 3 layers will get the weights from the checkpoint and the last 3 layers will be randomly initialized and must be trained for your task.Facing this issue in test.py