devymex opened a new issue #13485: Found bug in caffe convert tool and solved
URL: https://github.com/apache/incubator-mxnet/issues/13485
 
 
   With following prototxt, the "_parse_proto" function will return empty 
"output_name"
   
   ```
   With a prototxt:
   layer {
     name: "data"
     type: "Input"
     top: "data"
     input_param {
       shape {
         dim: 1
         dim: 3
         dim: 128
         dim: 128
       }
     }
   }
   layer {  
     name: "test"  
     type: "InnerProduct" 
     bottom: "data"  
     top: "output"  
     inner_product_param {   
       num_output: 128   
       weight_filler {
          type: "xavier"
       }    
       bias_filler {     
          type: "constant"
          value: 1
       }
     }
   }
   layer {
      name: "sigmoid"
      type: "Sigmoid"
      bottom: "output"
      top: "output"
   }
   
   ```
   
   It is because the last layer "sigmoid" has identical bottom and top, making 
the "_output_name['output']['count']" equals to 2:
   
https://github.com/apache/incubator-mxnet/blob/9adf2148322547d36dd90045647122a4ea649661/tools/caffe_converter/convert_symbol.py#L152
   
https://github.com/apache/incubator-mxnet/blob/9adf2148322547d36dd90045647122a4ea649661/tools/caffe_converter/convert_symbol.py#L157
   
   Then it failed to pass the condition in:
   
https://github.com/apache/incubator-mxnet/blob/9adf2148322547d36dd90045647122a4ea649661/tools/caffe_converter/convert_symbol.py#L292
   
   Finally, I adding a condition before the two loops and the problem solved:
   ```
           if layer.bottom != layer.top:
               for k in range(len(layer.bottom)):
                   if layer.bottom[k] in _output_name:
                       _output_name[layer.bottom[k]]['count'] = 
_output_name[layer.bottom[k]]['count']+1
                   else:
                       _output_name[layer.bottom[k]] = {'count':0}
               for k in range(len(layer.top)):
                   if layer.top[k] in _output_name:
                       _output_name[layer.top[k]]['count'] = 
_output_name[layer.top[k]]['count']+1
                   else:
                       _output_name[layer.top[k]] = {'count':0, 'name':name}
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to