标题已经包含完整的问题:如何使用Pycaffe获取Caffe模型的给定图层的输出形状?
我有一个caffe.Net()
对象,现在我想要模型中特定图层的输出形状。
给定图层名称,您可以通过以下方式获取其索引:
l_idx = list(net._layer_names).index(my_layer_name)
一旦你有l_idx
,你可以得到它的输出(aka "top"
s):
tops = [(net._blob_names[bi], net.blobs[net._blob_names[bi]].data.shape)
for bi in list(net._top_ids(li))]
对于每个"top"
,您可以获得信息
for tn in tops:
print "output name {} has shape {}".format(tn, net.blobs[tn].data.shape)
有关如何通过pycaffe接口访问网络结构的更详细示例可以找到here。