Reputation: 26004
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 .
Upvotes: 2
Views: 1902
Reputation: 114866
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
Upvotes: 3