Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown layer type (crop) in Caffe for windows

Tags:

python

caffe

I want to use the following convolutional neural network:

http://lmb.informatik.uni-freiburg.de/people/ronneber/u-net/

with caffe built from https://github.com/BVLC/caffe/tree/windows

for windows 10 with visual studio 2013, CUDA 7.5, cudNN 4 and python support.

Now, when i call either of the two networks supplied with

net = caffe.Net('xyz.prototxt', 'xyz.caffemodel', caffe.TEST)

I get the following error:

 Error parsing text-format caffe.NetParameter: 43:85: Unknown enumeration value of "CROP" for field "type".

Line 43 of the network looks as follows:

layers { bottom: 'd3c' bottom: 'u3a' top: 'd3cc'  name: 'crop_d3c-d3cc'  type: CROP }

I have looked online and some people seem to encounter the same error message. I could not find any solutions, however.

My question now is: how do I get rid of this error?

Help is greatly appreciated!

EDIT:

Changing the .prototxt as suggested by Dale Song eliminated this error, but led to another one:

[libprotobuf ERROR ..\src\google\protobuf\text_format.cc:274] Error parsing text-format caffe.NetParameter: 10:102: Message type "caffe.LayerParameter" has no field named "blobs_lr".

I fixed this by replacing

blobs_lr: 1 weight_decay: 1 blobs_lr: 2 weight_decay: 0

with

 param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0}

in the .prototxt, as suggested here.

Thanks!

like image 305
warped Avatar asked Sep 10 '16 16:09

warped


1 Answers

Solution:

You should modify net.prototxt from:

layers { ... type: CROP } to

layer { ... type: "Crop" }

and meanwhile, other layers' parameter in the prototxt should also be modified similarly to:

layer { ... type: "TypeString" },

and the TypeString can be found from:

  1. The line REGISTER_LAYER_CLASS(some_layer_name) in related some_layer_name_layer.cpp file. For example, REGISTER_LAYER_CLASS(Data) in data_layer.cpp means the TypeString should be Data when writing a data layer in net.prototxt.
  2. REGISTER_LAYER_CREATOR(some_layer_name, GetSomeLayer) in layer_factory.cpp. For example, REGISTER_LAYER_CREATOR(Convolution, GetConvolutionLayer) means the TypeString should be Convolution when writing a convolution layer in net.prototxt.

Reason:

The reason for your problem is: you used an old layer parameter format

layers { ... type: SOMELAYERNAME }.

and this format coming from V1LayerParameter in caffe.proto doesn't support some newer layer type including the crop layer.

You can confirm this by checking that enum LayerType of V1LayerParameter doesn't include layer type CROP.

To avoid this probelm, you can always use the newest format:

layer { ... type: "TypeString" }

in which the TypeString can be found in the 2 places mentioned above.


Edit 1

A simple remark:

In general, the error:

Error parsing text-format caffe.xxxParameter: ...

can always be solved by checking that the xxx.prototxt files use the right field names declared in caffe.proto and right values are assigned to them(by checking the field type and its value range).

like image 172
Dale Avatar answered Sep 21 '22 22:09

Dale