question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: You are trying to load a weight file containing 428 layers into a model with 114 layers.

See original GitHub issue

I have trained a segmentation model, the backbone is densenet201 with pretrained model, the decoder is FPN But, when I load saved weight for predicting,raise error as below:

Traceback (most recent call last):
  File "test.py", line 62, in <module>
    main()
  File "test.py", line 57, in main
    apply_predict()
  File "test.py", line 27, in apply_predict
    model.load_weights("models/densenet201_fpn_w.h5")
  File "/home/jiangd/.conda/envs/tf110/lib/python3.5/site-packages/keras/engine/network.py", line 1166, in load_weights
    f, self.layers, reshape=reshape)
  File "/home/jiangd/.conda/envs/tf110/lib/python3.5/site-packages/keras/engine/saving.py", line 1030, in load_weights_from_hdf5_group
    str(len(filtered_layers)) + ' layers.')
ValueError: You are trying to load a weight file containing 428 layers into a model with 114 layers.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
qubvelcommented, Aug 2, 2019

Now I am working on adopting all models for tf.keras (you can check in tf.keras branch), after that I am going to make some tutorials with training/inference

2reactions
qubvelcommented, Aug 2, 2019

To load model use:

import segmentation_models # important!
from keras.models import load_model

model = load_model('path/model.h5')

Hope this helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loading saved model fails with ValueError You are trying to ...
Loading saved model fails with ValueError You are trying to load a weight file containing 1 layers into a model with 0 layers...
Read more >
ValueError: You are trying to load a weight file containing 6 ...
It seems models with InputLayer are not serialized to HDF5 correctly. Upgrade your Tensorflow and Keras to the latest version. Fix the ...
Read more >
You are trying to load a weight file containing 0 layers into a ...
I'am currently using keras 2.1.5 in anaconda(windows). This is the error when I'am trying to load the weights file available online into VGG16...
Read more >
You are trying to load a weight file containing 0 layers into a ...
ValueError : You are trying to load a weight file containing 0 layers into a model with 16 layers. ... 428: 'barrow, garden...
Read more >
tensorflow/python/keras/engine/training.py | Fossies
If the model has multiple outputs, 499 you can use a different loss on each ... 744 raise ValueError('Your model contains layers that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found