Given a caffe.Net
object, what's the best way to access a particular layer?
Right now I only figured how to iterate over them, which is not very useful:
for i in range(n_layers):
print net.layers[i].type
Given a caffe.Net
object, what's the best way to access a particular layer?
Right now I only figured how to iterate over them, which is not very useful:
for i in range(n_layers):
print net.layers[i].type
You can get all the layers' names by
of course if you want to inspect the values of the learned parameters, you can see how it's done in this net surgery example.
For instance, if you want to inspect the filters of
conv1
layer (assuming you have a layer with that name in your model) you can accessAnd the bias term of this layer
As you can see, this is the first layer of an image processing net, it has 64 filters acting on 3x3 patches of BGR (3 channels) input.
If you already fed data through the net (using
net.forward
, ornet.backward
) you can inspect the responses of the different layers to the specific inputs fed through the net:The output shape of
conv1
layer is 198x198 pixels with 64 channels (there are 64 filters in this layer) and the batch size is 1.If you performed a backward pass as well, you can also inspect the gradients computed at this layer: