【发布时间】:2017-06-19 03:19:26
【问题描述】:
是否有可能在 pycaffe 中获取每一层的类型(例如:卷积、数据等)? 我搜索了提供的示例,但找不到任何东西。目前我正在使用图层名称来完成我的工作,这是非常糟糕和限制性的。
【问题讨论】:
标签: neural-network deep-learning caffe pycaffe
是否有可能在 pycaffe 中获取每一层的类型(例如:卷积、数据等)? 我搜索了提供的示例,但找不到任何东西。目前我正在使用图层名称来完成我的工作,这是非常糟糕和限制性的。
【问题讨论】:
标签: neural-network deep-learning caffe pycaffe
很简单!
import caffe
net = caffe.Net('/path/to/net.prototxt', '/path/to/weights.caffemodel', caffe.TEST)
# get type of 5-th layer
print "type of 5-th layer is ", net.layers[5].type
要在图层名称和索引之间进行映射,您可以使用这个简单的技巧:
idx = list(net._layer_names).index('my_layer')
print "The index of \'my_layer\' is ", idx, " and the type is ", net.layers[idx].type
【讨论】:
"data" 的层吗?
blob 名称和layer 名称:blob 名称是"top"/"bottom"s 的参数,而图层名称是"name" 的参数。例如,您可能有一个名为"data" 的"Data" 层 产生blob "data" 和"label"。因此,您有一个名为 "label" 的 blob,但没有具有该名称的层。