I'm trying to read weight and bias in a caffe network with pycaffe. Here is my code
weight = net.params[layer_name][0].data
bias = net.params[layer_name][1].data
But, some layers in my network has no bias, so that there will be an error which is Index out of range
.
So my question is can I use
if(net.params[layer_name][1] exists):
bias = net.params[layer_name][1].data
to control the assignments to bias
?
And how to write the code?