如何获取pycaffe中的图层类型? [英] How can I get layer type in pycaffe?

查看:190
本文介绍了如何获取pycaffe中的图层类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能否在pycaffe中获取每个图层的类型(例如卷积,数据等)? 我搜索了提供的示例,但找不到任何东西.目前我正在使用图层名称来做我的工作,这是非常糟糕和局限的.

Is it possible at all to get each layer's type (e.g: Convolution, Data, etc) in pycaffe? I searched the examples provided, but I couldn't find anything. currently I'm using layers name to do my job which is extremely bad and limiting .

推荐答案

简单!

import caffe
net = caffe.Net('/path/to/net.prototxt', '/path/to/weights.caffemodel', caffe.TEST)

# get type of 5-th layer
print "type of 5-th layer is ", net.layers[5].type

要在图层名称和索引之间进行映射,可以使用以下简单技巧:

To map between layer names and indices you can use this simple trick:

idx = list(net._layer_names).index('my_layer')
print "The index of \'my_layer\' is ", idx, " and the type is ", net.layers[idx].type

这篇关于如何获取pycaffe中的图层类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆