amir-abdi / keras_to_tensorflow

General code to convert a trained keras model into an inference tensorflow model
MIT License
1.67k stars 539 forks source link

convert model failed: ValueError: Unknown loss function:quad_loss #78

Open globalmaster opened 5 years ago

globalmaster commented 5 years ago

Hi, I'm trying to convert my .h5 model to .json file on Ubuntu16.04 with keras==2.2.4 tensorflow-gpu==1.12.0. My .h5 model file can be download here: https://drive.google.com/open?id=1QVQiS4rsCuHFoQw-tarYLw6EqegIzMfD

I get this error: Traceback (most recent call last): File "keras_to_tensorflow.py", line 183, in app.run(main) File "/usr/local/lib/python3.5/dist-packages/absl/app.py", line 300, in run _run_main(main, args) File "/usr/local/lib/python3.5/dist-packages/absl/app.py", line 251, in _run_main sys.exit(main(argv)) File "keras_to_tensorflow.py", line 129, in main model = load_model(FLAGS.input_model, FLAGS.input_model_json, FLAGS.input_model_yaml) File "keras_to_tensorflow.py", line 106, in load_model raise wrong_file_err File "keras_to_tensorflow.py", line 63, in load_model model = keras.models.load_model(input_model_path) File "/usr/local/lib/python3.5/dist-packages/keras/engine/saving.py", line 419, in load_model model = _deserialize_model(f, custom_objects, compile) File "/usr/local/lib/python3.5/dist-packages/keras/engine/saving.py", line 312, in _deserialize_model sample_weight_mode=sample_weight_mode) File "/usr/local/lib/python3.5/dist-packages/keras/engine/training.py", line 139, in compile loss_function = losses.get(loss) File "/usr/local/lib/python3.5/dist-packages/keras/losses.py", line 133, in get return deserialize(identifier) File "/usr/local/lib/python3.5/dist-packages/keras/losses.py", line 114, in deserialize printable_module_name='loss function') File "/usr/local/lib/python3.5/dist-packages/keras/utils/generic_utils.py", line 165, in deserialize_keras_object ':' + function_name) ValueError: Unknown loss function:quad_loss

How can I fix this error? Can you help me?

amir-abdi commented 5 years ago

Check this thread: https://github.com/amir-abdi/keras_to_tensorflow/issues/46