Community
cancel
Showing results for 
Search instead for 
Did you mean: 
hsing__hj
Beginner
113 Views

How to make Model Optimizer to support Dropout layer

Hi,

I am try to do intel document id:576014(CPU and GPU Concurrent Pipelining of MODAC for the Intel® Computer Vision SDK Inference Engine) with cvsdk 2018.0.234.

When I use Model Optimizer to generate IR files. I got an error like this:

[ 2018-05-23 15:14:59,641 ] [ ERROR ] [ main:227 ]  Model Optimizer is not able to read barcode.prototxt. Possible reasons: 1. your caffemodel contains custom layers that are not supported in Model Optimizer by default. 2. your prototxt does not have a valid structure, e.g you downloaded it as html. In particular the first unknown field is message After you made sure that prototxt has a valid structure and still see this issue, then you need to generate a python parser for caffe.proto that was used when the model was created. Run "python3 generate_caffe_pb2.py --input_proto ${PATH_TO_CAFFE}/src/caffe/proto/caffe.proto". For more information please refer to Model Optimizer FAQ, question #1.
[ 2018-05-23 15:14:59,642 ] [ DEBUG ] [ main:228 ]  Traceback (most recent call last):
  File "/opt/intel/computer_vision_sdk_2018.0.234/deployment_tools/model_optimizer/mo/pipeline/caffe.py", line 59, in driver
    proto, model = loader.load_caffe_proto_model(proto_file_name, model_file_name)
  File "/opt/intel/computer_vision_sdk_2018.0.234/deployment_tools/model_optimizer/mo/front/caffe/loader.py", line 92, in load_caffe_proto_model
    model.MergeFromString(map)
google.protobuf.message.DecodeError: Error parsing message

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/intel/computer_vision_sdk_2018.0.234/deployment_tools/model_optimizer/mo/main.py", line 222, in main
    return driver(argv)
  File "/opt/intel/computer_vision_sdk_2018.0.234/deployment_tools/model_optimizer/mo/main.py", line 202, in driver
    custom_layers_mapping_path=custom_layers_mapping_path)
  File "/opt/intel/computer_vision_sdk_2018.0.234/deployment_tools/model_optimizer/mo/pipeline/caffe.py", line 71, in driver
    'For more information please refer to Model Optimizer FAQ, question #1.') from e
mo.utils.error.Error: Model Optimizer is not able to read barcode.prototxt. Possible reasons: 1. your caffemodel contains custom layers that are not supported in Model Optimizer by default. 2. your prototxt does not have a valid structure, e.g you downloaded it as html. In particular the first unknown field is message After you made sure that prototxt has a valid structure and still see this issue, then you need to generate a python parser for caffe.proto that was used when the model was created. Run "python3 generate_caffe_pb2.py --input_proto ${PATH_TO_CAFFE}/src/caffe/proto/caffe.proto". For more information please refer to Model Optimizer FAQ, question #1.

I found the error is cause by caffemodel was trained with Dropout layer like following:

layer {
  
  name: "drop12"
  
  type: "Dropout"
  
  bottom: "fire12/concat"
  
  top: "fire12/concat"
  
  dropout_param {
    
    dropout_ratio: 0.1
  
  }

}

When I remove all the dropout layer and then retrain the model, the Model Optimizer will not show the error.
How to make Model Optimizer to support Dropout layer?

Best regards,
Hj

0 Kudos
1 Reply
Zhen_Z_Intel
Employee
113 Views

Hi hsing,

We do support dropout layer, however this layers are useless during inference and might increase the inference time.
This layers can be automatically removed from the resulting Intermediate Representation. And you may can find following code in mo/pipeline/caffe.py

 remove_op_nodes(graph, {'op': 'Dropout'})

If you would like to keep this layer as custom layer, you can follow Extending the Model Optimizer with New Primitives

Reply