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.

The loaded model behaves inconsistently

See original GitHub issue

First of all, thank you for this awesome library!

I exported, and imported the model with this code:

# save weights
model.save_weights("model.h5")
from keras_segmentation.models.unet import vgg_unet

# load model
model_weight_path = 'model.h5'
model = vgg_unet(n_classes=6,  input_height=640, input_width=640)
model.load_weights(model_weight_path, by_name=True)

In some cases when I load the model, I got good prediction results that is middle in the table, and then if I use the same code, the same model, I got this strange result which is bottom in the table.

I use Google Colab, Keras 2.1.0. keras-segmentation-0.2.0

I installed keras-segmentation with pip. I tried with Keras 2.2.5 as well, and I got the same strange behavior.

What can it cause this phenomenon?

Thanks, for your help!

Original image top_potsdam_2_10_RGB
Good result top_potsdam_2_10_RGB_proc
Bad result top_potsdam_2_10_RGB_proc

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
divamguptacommented, Mar 13, 2020

@bessszilard , replace model.load_weights(model_weight_path, by_name=True) with model.load_weights(model_weight_path) and it should work fine!

1reaction
divamguptacommented, Mar 12, 2020

That is strange. Could you share some reproducible snippet or the maybe the collab notebook? I can take a look.

One reason causing the problem could be that weights of all the layers are not being loaded properly. That could be checked by comparing the weights.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python 3.x - Pytorch Loaded model giving inconsistent results
Now the model predicts the 0 has the output for every input. Is there anything wrong with way I saved the model or...
Read more >
Loading saved models gives inconsistent results each time
When I load multiple models one after another with below method only first gives expected results on the test, others fail.
Read more >
Legitimate cases of having .equals() behaving inconsistently ...
When the Java documentation says that these two methods must behave consistently, what they mean is that the .equals method must return true...
Read more >
How AWS dumps the mental burden of inconsistent APIs on ...
So functionally, they behave like the List operations in IAM. Inconsistency between related AWS services. Kinesis is a great example of ...
Read more >
10. Common pitfalls and recommended practices - Scikit-learn
10.2. Data leakage¶. Data leakage occurs when information that would not be available at prediction time is used when building the model. This...
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