本文介绍了Caffe for Windows中的未知图层类型(裁剪)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用以下卷积神经网络:





使用从 https://github.com/BVLC/caffe/tree/ Windows



适用于带有Visual Studio 2013,CUDA 7.5,cudNN 4和python支持的Windows 10。



现在,当我呼叫提供的两个网络之一

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

我收到以下错误:

 解析文本格式caffe.NetParameter时出错:43:85:字段 type的 CROP的未知枚举值。 

网络的第43行如下所示:

  layers {底部:'d3c'底部:'u3a'顶部:'d3cc'名称:'crop_d3c-d3cc'类型:CROP} 

我在网上看过,有些人似乎遇到了同样的错误消息。但是,我找不到任何解决方案。



我现在的问题是:如何摆脱这个错误?



非常感谢您的帮助!



编辑:



更改。 建议的prototxt消除了此错误,但导致了另一个错误:

  [libprotobuf错误..\src\google\protobuf\text_format.cc:274]解析文本格式caffe.NetParameter时出错:10:102:消息类型 caffe.LayerParameter没有名为 blobs_lr的字段。 

我通过替换

  blobs_lr:1 weight_decay:1 blobs_lr:2 weight_decay:0 
 参数{lr_mult:1衰减_mult:1}参数{lr_mult:2衰减_mult:0} 

,如建议。



谢谢!

解决方案

解决方案:



您应修改 net.prototxt 来自:



layers {... type:CROP}



图层{...类型:作物}



原型中的其他层的参数也应类似于以下内容进行修改:



layer {... type: TypeString}



TypeString 可以从以下位置找到:




  • 相关的 some_layer_name_layer.cpp 文件中的 REGISTER_LAYER_CLASS(some_layer_name)行。例如, data_layer.cpp 中的 REGISTER_LAYER_CLASS(Data)表示 TypeString net.prototxt 中写入数据层时,$ c>应该是 Data

  • REGISTER_LAYER_CREATOR(some_layer_name,GetSomeLayer) layer_factory.cpp 中。例如, REGISTER_LAYER_CREATOR(Convolution,GetConvolutionLayer)表示 TypeString 应该为 Convolution net.prototxt 中写卷积层时。

  • 原因:



    出现问题的原因是:您使用了旧的图层参数格式



    layers {...类型:SOMELAYERNAME}



    ,此格式来自V1LayerParameter caffe / blob / windows / src / caffe / proto / caffe.proto rel = nofollow> caffe.proto 不支持某些较新的图层类型,包括 crop 层。



    您可以通过检查 V1LayerParameter的枚举LayerType 来确认这一点。 不包含图层类型 CROP



    为避免这种问题,您可以始终使用最新格式:



    图层{... type: TypeString}



    其中 TypeString 可以可以在上述2个地方找到。






    编辑1



    一个简单的注释:



    通常,错误:

     解析文本格式caffe.xxx时出错:... 

    始终可以通过检查 xxx.prototxt 文件使用在并为其分配正确的值(通过检查字段类型及其值范围。)


    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!

    解决方案

    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:

  • 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.
  • 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).

    这篇关于Caffe for Windows中的未知图层类型(裁剪)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    09-16 09:10