rabi3elbeji / SteganalysisCNN

An Improved CNN Steganalysis Architecture Based on “Catalyst Kernels” and Transfer Learning
MIT License
25 stars 12 forks source link

ValueError: Shapes are incompatible #3

Open silent-code opened 4 years ago

silent-code commented 4 years ago

Hi, I've preprocessed my data set according to preprocess_dataset.py and then I run train.py and get the following error

Traceback (most recent call last): File "train.py", line 210, in main() File "train.py", line 171, in main model.set_weights([preprocess_weights]) File "/Users/tz/.virtualenvs/dl4cv/lib/python3.7/site-packages/keras/engine/network.py", line 527, in set_weights K.batch_set_value(tuples) File "/Users/tz/.virtualenvs/dl4cv/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 2960, in batch_set_value tf_keras_backend.batch_set_value(tuples) File "/Users/tz/.virtualenvs/dl4cv/lib/python3.7/site-packages/tensorflow_core/python/keras/backend.py", line 3343, in batch_set_value x.assign(np.asarray(value, dtype=dtype(x))) File "/Users/tz/.virtualenvs/dl4cv/lib/python3.7/site-packages/tensorflow_core/python/ops/resource_variable_ops.py", line 814, in assign self._shape.assert_is_compatible_with(value_tensor.shape) File "/Users/tz/.virtualenvs/dl4cv/lib/python3.7/site-packages/tensorflow_core/python/framework/tensor_shape.py", line 1115, in assert_is_compatible_with raise ValueError("Shapes %s and %s are incompatible" % (self, other)) ValueError: Shapes (5, 5, 128, 4) and (5, 5, 1, 4) are incompatible

I presume my data are (1, 128, 128) at the input. Any thoughts on the incompatibility error?

Thanks in advance, Tim

silent-code commented 4 years ago

Solution:

In train.py make the following change:

K.set_image_dim_ordering('tf')

K.set_image_data_format('channels_last')