Can't load weight
Closed this issue · 5 comments
Please refer to Question.
I am getting error in this line : model.layers[k].set_weights(weights)
Following is the error:
ValueError: Layer weight shape (3L, 3L, 3L, 64L) not compatible with provided weight shape (64, 3, 3, 3)
Please help
Hi @som2014, that looks like a dim ordering issue. Are you using the tensorflow backend or the theano backend? They use different image data formats, with the number of channels (3 in this case, either at the front or at the end of the weight shape.
See here: https://stackoverflow.com/questions/47990621/image-ordering-tensor-flow or Google around about tensorflow and thano dim ordering for more details.
tldr, I think you could fix your problem by either reshaping your data or using a different keras backend.
@rdcolema error is coming in save_bottleneck_features()
my json file look like this
{
"backend": "theano",
"epsilon": 1e-07,
"floatx": "float32",
"image_dim_ordering": "tf"
}
```I had tried some workaround but nothing works any suggestion please ?
Try changing "image_dim_ordering" to "th" and see if that helps.
I had already try that workaround changed it "th" and also using this code K.set_image_dim_ordering('th')
but still same error
Have you tried modifying the line model.add(ZeroPadding2D((1, 1), input_shape=(3, img_width, img_height)))
?
I also might try printing/logging K.image_dim_ordering()
before the error to make sure the configuration is what you expect. The other part of that function that could be affecting it is the model that's being loaded from the h5py file -- if the weights use a different ordering there that might be conflicting with something.
For the record this is also really old code built off a much earlier version of keras, so there's a good chance some things have changed under the hood since then too.