kentsommer / keras-inceptionV4

Keras Implementation of Google's Inception-V4 Architecture (includes Keras compatible pre-trained weights)
Apache License 2.0
471 stars 175 forks source link

Shape of layers doesn't match the saved weight file #23

Closed michalo1 closed 2 years ago

michalo1 commented 6 years ago

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.

kentsommer commented 6 years ago

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

mannykoum commented 5 years ago

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

jeffersonlicet commented 5 years ago

Any info about this?

Subrat08 commented 4 years ago

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.

kentsommer commented 2 years ago

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.