Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting pycaffe layer name or blob type

I have some CNN called net for which I'd like to know the type of the blob or the name of the layer.

For example, I can easily access the blob name and the subsequent blob:

for blob in net.blobs:
    print(blob)
    net.blobs[blob]...

Or, I can access the layer type:

for x in range(len(net.layers)):
    print(net.layers[x].type)

Is there anyway to access this information like:

net.blobs[blob].type

or,

net.layers[x].name

Thanks

like image 814
Shaun Barney Avatar asked Apr 16 '26 04:04

Shaun Barney


1 Answers

A blob does not have type. It's a blob: a container for N-dimensional data. You may look for net.blobs[blob].data.shape for its shape, or look for net.blobs[blob].diff for computed gradients (if you backprop the gradients...)

Layers' names are stored in net._layer_names. You can get the index of a layer by idx = list(net._layer_names).index('my_layer').

See this thread for more info.

like image 131
Shai Avatar answered Apr 18 '26 04:04

Shai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!