-
Notifications
You must be signed in to change notification settings - Fork 19.4k
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
Retrained MobileNet and failed to load it for prediction #7431
Comments
MobileNet uses several custom functions. You need to use a
CustomObjectScope to load a saved model (see docs entry about it). The
custom objects can be imported from keras.applications.mobilenet.
…On Jul 25, 2017 19:30, "Ronald Tao" ***@***.***> wrote:
TF: 1.2.1-gpu
Keras: 2.0.6
I am trying to retrain the MobileNet modle from the latest version using
the following script,
Training.py
https://gist.github.com/rtao/50eb8c96b06f4deddec2b7888da1d062
And when I try to load it back with the following, I got an error of
"ValueError: Unknown activation function:relu6"
Predict.py
https://gist.github.com/rtao/c6773e7e430552a54a3812d5fae91bfe
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#7431>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AArWb2oDqQe1FT94akwlpvfEd6SDEO1kks5sRs8DgaJpZM4OjctN>
.
|
Just to make @fchollet's comment explicit for fellow n00bs like me...this works:
|
If your keras is at "from tensorflow.python import keras" instead of at "import keras" then here is what worked for me:
|
Is still possible to import |
I have found |
had same issue with keras 2.2.0, no relu6 is found. |
i downgraded to 2.1.4, it works fine. noticed pr on removing relu6 in 2.2, but the pretrained model still has it. |
im using Keras 2.2 with tensorflow 1.9 any idea how the import for DepthwiseConv2D should look like ? |
Found them,
Just for information, before they were imported as
|
In Keras2.2, modified to with CustomObjectScope({'relu6': keras.layers.ReLU(6.),'DepthwiseConv2D': keras.layers.DepthwiseConv2D}): |
Im still facing the same issue! |
How to convert MobileNet from Keras 2.1.3 to CoreML?
This also gives |
Here is solution based on apple/coremltools#38
And here is as solution for keras to tflite |
I have tried but I got the following error: my TF is 1.11 my keras is 2.2.4, python 2.7. |
in version >= 2.2.4, you can write like this:
|
|
I am having some trouble with this error and I don't know what to do. I am having a hard time because the way I am saving my trained model is different. What should I do? Savingmodel_json = model.to_json() model.save_weights("model_pretrained.h5") Loadingjson_file = open('model_pretrained.json', 'r') loaded_model = model_from_json(loaded_model_json) ValueError: Unknown activation function:relu6 |
Closing this issue since its resolved. Feel free to reopen if have further problems. Thanks! |
i don't know, |
@rtao @fchollet |
TF: 1.2.1-gpu
Keras: 2.0.6
I am trying to retrain the MobileNet modle from the latest version using the following script,
Training.py
https://gist.github.com/rtao/50eb8c96b06f4deddec2b7888da1d062
And when I try to load it back with the following, I got an error of "ValueError: Unknown activation function:relu6"
Predict.py
https://gist.github.com/rtao/c6773e7e430552a54a3812d5fae91bfe
The text was updated successfully, but these errors were encountered: