marcellacornia / mlnet

A Deep Multi-Level Network for Saliency Prediction. ICPR 2016
MIT License
94 stars 37 forks source link

Exception: Layer weight shape (3, 3, 640, 64) not compatible with provided weight shape (64, 3, 3, 3) #22

Closed kmamine closed 4 years ago

kmamine commented 4 years ago

Hi I read the previous Issues , #1 #7 #2 , I am using Google Colab with these packeges installed python 2.7 theano 0.9.0 and Keras 1.1.0

These are my Keras.json configs : { "epsilon": 1e-07, "floatx": "float32", "image_data_format": "th", "backend": "theano" }.

the issue with the model Loading VGG weights still persists

`Using Theano backend.

Traceback (most recent call last):

File "main.py", line 43, in

model = ml_net_model(img_cols=shape_c, img_rows=shape_r, downsampling_factor_product=10)

File "/content/mlnet/model.py", line 27, in ml_net_model

conv1_1 = Convolution2D(64, 3, 3, weights=weights, activation='relu', border_mode='same')(input_ml_net)

File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 487, in call self.build(input_shapes[0])

File "/usr/local/lib/python2.7/dist-packages/keras/layers/convolutional.py", line 437, in build self.set_weights(self.initial_weights)

File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 889, in set_weights 'provided weight shape ' + str(w.shape))

Exception: Layer weight shape (3, 3, 640, 64) not compatible with provided weight shape (64, 3, 3, 3) `

marcellacornia commented 4 years ago

Hi @kmamine, the json file should contain "image_dim_ordering": "th" instead of "image_data_format": "th".

kmamine commented 4 years ago

Thank you, the error is gone , i didn't notice that, What Numpy Version did you use ?

I got the following error :
AttributeError: ('The following error happened while compiling the node', DeepCopyOp(convolution2d_1_W), '\n', "'module' object has no attribute '_get_ndarray_c_version'")

looks like old Theano Breaks with the new Numpy versions .

rabeya-akter commented 3 years ago

Hi @kmamine, the json file should contain "image_dim_ordering": "th" instead of "image_data_format": "th".

how can I change it?