I'm following the net_surgery.ipynb example of caffe which explains how to modify the weights of a saved .caffemodel
. However since I'm quite new to python I can't understand some of the syntax.
Can someone explain me what the 7th line starting with conv_params = {pr: ...
means in the code example given below? (example is from net_surgery.ipynb - step 8). Especially what is pr:
? Is it a key in a (key,value) like structure?
# Load the fully convolutional network to transplant the parameters.
net_full_conv = caffe.Net('net_surgery/bvlc_caffenet_full_conv.prototxt',
'../models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel',
caffe.TEST)
params_full_conv = ['fc6-conv', 'fc7-conv', 'fc8-conv']
# conv_params = {name: (weights, biases)}
conv_params = {pr: (net_full_conv.params[pr][0].data, net_full_conv.params[pr][1].data) for pr in params_full_conv}
for conv in params_full_conv:
print '{} weights are {} dimensional and biases are {} dimensional'.format(conv, conv_params[conv][0].shape, conv_params[conv][1].shape)