Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load re-trained model error #4

Closed
leviome opened this issue Dec 5, 2018 · 10 comments
Closed

load re-trained model error #4

leviome opened this issue Dec 5, 2018 · 10 comments

Comments

@leviome
Copy link

leviome commented Dec 5, 2018

at the beginning, 'demo.py' ran successfully with pretrained model.
then, after preparing and converting data, I retrained the model by

python train.py --dataset ./DIV2K_BIN --outdir ./output --profile wdsr-a-8 --scale 2

it ran normally for 300 epochs, and I got many new h5 files. when I loaded one of new h5 files, error occurred:

TypeError: Expected float32, got {'type': 'ndarray', 'value': [114.44399999999999, 111.4605, 103.02000000000001]} of type 'dict' instead.
could you offer me some suggestions?

@krasserm
Copy link
Owner

krasserm commented Dec 5, 2018

Please provide details how you loaded the h5 file.

@leviome
Copy link
Author

leviome commented Dec 5, 2018

python demo.py -i ./demo -o ./output --model ./output/20181204-230641/models/epoch-300-psnr-37.7157.h5
'epoch-300-psnr-37.7157.h5' is the new h5 file. And,
python bench.py -i ./output/20181204-230641/models -o bench.json had the same error information.

@krasserm
Copy link
Owner

krasserm commented Dec 5, 2018

I'm afraid I cannot reproduce your problem i.e. the commands you provided work as expected in my environment. What versions of Keras and Tensorflow do you use?

@krasserm
Copy link
Owner

krasserm commented Dec 5, 2018

Probably you ran into keras-team/keras#11281

@leviome
Copy link
Author

leviome commented Dec 6, 2018

tensorflow==1.9.0
tensorflow-gpu==1.9.0
keras==2.2.0
I upgraded keras version to 2.2.4, the error still existed.
may I know your version of tf and keras

@krasserm
Copy link
Owner

krasserm commented Dec 6, 2018

You will need to re-train the model as the h5 files have been written with the older Keras version. For a quick test, can you please train the model again for only 1 epoch and then use the generated h5 file with the demo? This should work now. I'm using Keras 2.2.4 and tested with Tensorflow 1.10 and 1.12.

@leviome
Copy link
Author

leviome commented Dec 6, 2018

thanks a lot!
I retrained it with keras 2.2.4, and the new model is available for demo.py.
Your suggestions helped much!

@krasserm
Copy link
Owner

krasserm commented Dec 6, 2018

You're welcome, glad it worked!

@krasserm krasserm closed this as completed Dec 6, 2018
@ink1
Copy link

ink1 commented Apr 27, 2019

this helped me too. consider adding keras=2.2.4 as a requirement.
and many thanks for sharing. much appreciated!

@ngonthier
Copy link

Sorry but it doesn't work for me to update keras to 2.2.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants