Shaun Barney
Shaun Barney

Reputation: 738

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

Upvotes: 3

Views: 2674

Answers (1)

Shai
Shai

Reputation: 114866

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.

Upvotes: 2

Related Questions