2016-12-12 82 views
0

我想了解卷積神經網絡SegNet是做什麼的,因此我創建了一個Python模塊來支持它,希望能夠打印出其圖層的不同形狀和屬性。pycaffe無法識別原型文件中的有效參數

from __future__ import print_function 
import numpy as np 
import matplotlib.pyplot as plt 
from PIL import Image 
import caffe 

caffe.set_device(0) 
caffe.set_mode_gpu() 
net = caffe.Net('/path/to/models/segnet_train.prototxt', caffe.TEST) 

[print(k, v.data.shape) for k, v in net.blobs.items()] 

但它告訴我,該文件是不正確的,雖然我可以正確地培養這個網與SegNet提供的文件(見prototxt文件here)。這是什麼意思,我該怎麼辦?

以下是完整的錯誤

[libprotobuf ERROR google/protobuf/text_format.cc:274] Error parsing text-format caffe.NetParameter: 7:26: Message type "caffe.LayerParameter" has no field named "dense_image_data_param". 
WARNING: Logging before InitGoogleLogging() is written to STDERR 
F1212 15:59:09.624486 20202 upgrade_proto.cpp:88] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: /path/to/models/segnet_train.prototxt 
+1

此帖子http://stackoverflow.com/a/39432128/6281477可能會爲您提供一些提示。 – Dale

+0

謝謝!不完全是我的錯誤。我還沒有任何修改,因此我已將_dense \ _image \ _data \ _param_更改爲_image \ _data \ _param_。現在錯誤已經變成'...沒有參數「bn_param」'。我發現了一些東西[這裏](https://github.com/alexgkendall/SegNet-Tutorial/issues/13),但我不明白。你可以幫我嗎? – BusyAnt

+1

我想你沒有安裝SegNet所需的正確版本的caffe。因爲不同版本的caffe在'src/caffe/layers /'文件夾中可能有不同的'caffe.proto'和不同的圖層。 – Dale

回答

1

正如戴爾在他的comment指出的那樣,這確實是一個朱古力版本問題。我確實使用了一個獨立的caffe構建,而SegNet則有自己的caffe。

我改變了python路徑到這個發行版,並且一切正常。