kentsommer / keras-inceptionV4

Keras Implementation of Google's Inception-V4 Architecture (includes Keras compatible pre-trained weights)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shape of layers doesn't match the saved weight file

michalo1 opened this issue · comments

In version 2.1, loading the model like this:
inception_v4.create_model(include_top=False, weights='imagenet')
throws an exception:

Traceback (most recent call last):
...
File "/models/inception_v4/inception_v4.py", line 268, in inception_v4
  model.load_weights(weights_path, by_name=True)
File "/venv/lib/python3.6/site-packages/keras/engine/network.py", line 1177, in load_weights
  reshape=reshape)
File "/venv/lib/python3.6/site-packages/keras/engine/saving.py", line 1018, in load_weights_from_hdf5_group_by_name
  str(weight_values[i].shape) + '.')
ValueError: Layer #305 (named "conv2d_98"), weight <tf.Variable 'conv2d_98/kernel:0' shape=(3, 3, 64, 96) dtype=float32_ref> has shape (3, 3, 64, 96), but the saved weight has shape (192, 1024, 1, 1).

//edit: Seems like the issue occurs only if I have InceptionV3 model used along with InceptionV4 in the same script.

If you can provide a minimal script to reproduce the error I will take a look at it @michalo1

I am getting a similar error on the first convolutional layer with include_top=False. Will try to write script to reproduce error.

Any info about this?

I tried rerunning the code and it works fine, but first 2-3 times I get the same error. Also, I don't know why it gives the same class label for most of the images.

Closing this out after a long hiatus from Github.

If folks are still seeing issues, I am happy to accept pull requests to fix things as I likely won't have the time.