- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I was working on Keras to train a model. I have used ResNet50 model with imageNet weights and I did fine-tuning on model and save weights as *.h5.
I have looked documentation convert tensorflow to IR and seen that freezing is required, I write a python code to convert .h5 file to .pb(with freeze operation). However when I tried model_optimizer to convert my model to IR there are some erros that I couldn't figure out.
python mo.py --input_model <path_to_model>
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] FusedBatchNorm doesn't support is_training=True
[ ERROR ] Cannot infer shapes or values for node "sequential_1/dropout_1/cond/Switch".
[ ERROR ] 0
[ ERROR ]
[ ERROR ] It can happen due to bug in custom shape infer function <function tf_native_tf_node_infer at 0x7f5e93619378>.
[ ERROR ] Or because the node inputs have incorrect values/shapes.
[ ERROR ] Or because input shapes are incorrect (embedded to the model or passed via --input_shape).
[ ERROR ] Run Model Optimizer with --log_level=DEBUG for more information.
[ ERROR ] Stopped shape/value propagation at "sequential_1/dropout_1/cond/Switch" node.
For more information please refer to Model Optimizer FAQ (<INSTALL_DIR>/deployment_tools/documentation/docs/MO_FAQ.html), question #38.
can anyone help me?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Have tried building with keras and found out that
after saving the weights as *h5,
1)remove all dropout and batch normalisation layers from your keras model
2)then freeze graph to .pb file
3)then use model_optimizer to convert model to IR
and you should be able to get the resulted xml and bin files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Kürsat and Kai,
I created a python file (PM me to get it) that basically resumes the steps described by Kai, the line: K.set_learning_phase(0) sets the model in inference mode (withdrawing the dropout and modifying the BatchNorm layer). Then, the model is converted to Tensorflow and is frozen. It is a simplified version of this code: https://github.com/alanswx/keras_to_tensorflow/blob/master/convertkeras.py
Best,
Severine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
mistake on my part.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for explanation kai, and thanks for the code, Severine. It worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Habert Would you mind sharing that script? I'm thinking of using it to convert a Keras model for the Movidius NCS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Habert,
Could you please share the script to convert Keras to Tensorflow model and to freeze the same. I need to load the same to convert the model to IR form by Model Optimiser.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Habert, Severine (Intel) wrote:Dear Kürsat and Kai,
I created a python file (PM me to get it) that basically resumes the steps described by Kai, the line: K.set_learning_phase(0) sets the model in inference mode (withdrawing the dropout and modifying the BatchNorm layer). Then, the model is converted to Tensorflow and is frozen. It is a simplified version of this code: https://github.com/alanswx/keras_to_tensorflow/blob/master/convertkeras.py
Best,
Severine
Dear Severine, I used the code that you are mentioning, but the problem persists. Can you provide your script?
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page