I would like to be able to extract all of the kernel sizes and strides for each of the pooling and convolutional layers in a pycaffe network. This seems to be possible since I see it being used in the drawing function (see line 94 here https://github.com/BVLC/caffe/blob/daf013931b31ed9c95250a89d09b7220badbcefe/python/caffe/draw.py)
Unfortunately when I attempt to use this syntax in this way:
net = caffe.Net(model_def, # defines the structure of the model
model_weights, # contains the trained weights
caffe.TEST) # use test mode (e.g., don't perform dropout)
# For each layer
for layer_name, layer in net.layer_dict.iteritems():
if layer.type == 'Convolution':
print layer.type
print layer.convolution_param.kernel_size[0] if len(layer.convolution_param.kernel_size) else 1
I receive the following error:
Convolution
AttributeError: 'Layer' object has no attribute 'convolution_param'
This is strange because I clearly am partially right as layer.type is working correctly since I am able to successfully make the check and only attempt to extract convolutional parameters for a convolutional layer. What is going wrong? When I attempt to see what kind of an object "layer" is I see this:
<caffe._caffe.Layer object at 0x7fe3a2fad050>
So this means it is in fact a PyCaffe layer object. I've looked everywhere for a PyCaffe Layer class reference but haven't come up with anything. Does anyone know of a good reference or how to properly extract kernel and stride information?
draw.pyI see a loop over thelayerattribute and notlayer_dict(line 153:for layer in caffe_net.layer). Have you tried doing it this way? - kostekcaffe.Net()call is notcaffe.proto.caffe_pb2.NetParameterthat is used indrawp.py. You should probably get this info from blobs. Check this blogpost: christopher5106.github.io/deep/learning/2015/09/04/… - kostekcaffe.proto.caffe_pb2.NetParameterthat is used indraw.py? - Kantthpel