如何在pycaffe中获取图层类型?

时间:2017-02-02 06:36:09

标签: neural-network deep-learning caffe pycaffe

是否可以在pycaffe中获取每个图层的类型(例如:卷积,数据等)? 我搜索了提供的示例,但我找不到任何东西。目前我正在使用图层名称来完成我的工作,这是非常糟糕和限制。

1 个答案:

答案 0 :(得分:2)

这很容易!

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