Unknown layer type (crop) in Caffe for windows
<p>I want to use the following convolutional neural network:</p>

<p><a href="http://lmb.informatik.uni-freiburg.de/people/ronneber/u-net/" rel="nofollow">http://lmb.informatik.uni-freiburg.de/people/ronneber/u-net/</a></p>

<p>with caffe built from <a href="https://github.com/BVLC/caffe/tree/windows" rel="nofollow">https://github.com/BVLC/caffe/tree/windows</a></p>

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

<p>Now, when i call either of the two networks supplied with</p>

<pre><code>net = caffe.Net('xyz.prototxt', 'xyz.caffemodel', caffe.TEST)
</code></pre>

<p>I get the following error:</p>

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

<p>Line 43 of the network looks as follows:</p>

<pre><code>layers { bottom: 'd3c' bottom: 'u3a' top: 'd3cc'  name: 'crop_d3c-d3cc'  type: CROP }
</code></pre>

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

<p>My question now is: how do I get rid of this error?</p>

<p>Help is greatly appreciated!</p>

<p><strong>EDIT:</strong></p>

<p>Changing the .prototxt as suggested by <a href="http://stackoverflow.com/a/39432128/6281477">Dale Song</a> eliminated this error, but led to another one:</p>

<pre><code>[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".
</code></pre>

<p>I fixed this by replacing </p>

<pre><code>blobs_lr: 1 weight_decay: 1 blobs_lr: 2 weight_decay: 0
</code></pre>

<p>with</p>

<pre><code> param {lr_mult: 1 decay_mult: 1} param {lr_mult: 2 decay_mult: 0}
</code></pre>

<p>in the .prototxt, as suggested <a href="https://groups.google.com/forum/#!topic/caffe-users/kEJzMjNmO_M" rel="nofollow">here</a>.</p>

<p>Thanks!</p>

<p><strong>Solution:</strong></p>

<p>You should modify <code>net.prototxt</code> from:</p>

<p><code>layers { ...  type: CROP }</code> to </p>

<p><code>layer { ...  type: "Crop" }</code></p>

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

<p><code>layer { ... type: "TypeString" }</code>,</p>

<p>and the <code>TypeString</code> can be found from:</p>

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

<p><strong>Reason:</strong></p>

<p>The reason for your problem is: you used an old layer parameter format</p>

<p><code>layers { ...  type: SOMELAYERNAME }</code>. </p>

<p>and this format coming from <code>V1LayerParameter</code> in <a href="https://github.com/BVLC/caffe/blob/windows/src/caffe/proto/caffe.proto" rel="nofollow">caffe.proto</a> doesn't support some newer layer type including the <code>crop</code> layer.</p>

<p>You can confirm this by checking that <code>enum LayerType</code> of <code>V1LayerParameter</code>  doesn't include layer type <code>CROP</code>. </p>

<p>To avoid this probelm, you can always use the newest format:</p>

<p><code>layer { ... type: "TypeString" }</code></p>

<p>in which the <code>TypeString</code> can be found in the 2 places mentioned above.</p>

<hr>

<p><strong>Edit 1</strong> </p>

<p><strong>A simple remark:</strong></p>

<p>In general, the error:</p>

<pre><code>Error parsing text-format caffe.xxxParameter: ...
</code></pre>

<p>can always be solved by checking that the <code>xxx.prototxt</code> files use the right field names declared in <a href="https://github.com/BVLC/caffe/blob/windows/src/caffe/proto/caffe.proto" rel="nofollow"><strong>caffe.proto</strong></a> and right values are assigned to them(by checking the field type and its value range).</p>

python caffe