How can I get layer type in pycaffe?

a 夏天 提交于 2019-12-12 19:03:27

问题


Is it possible at all to get each layer's type (e.g: Convolution, Data, etc) in pycaffe? I searched the examples provided, but I couldn't find anything. currently I'm using layers name to do my job which is extremely bad and limiting .


回答1:


It's easy!

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

To map between layer names and indices you can use this simple trick:

idx = list(net._layer_names).index('my_layer')
print "The index of \'my_layer\' is ", idx, " and the type is ", net.layers[idx].type


来源:https://stackoverflow.com/questions/41995678/how-can-i-get-layer-type-in-pycaffe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!