【问题标题】:How can I determine the input dimensions for a caffe blob如何确定 caffe blob 的输入尺寸
【发布时间】:2018-11-08 15:56:14
【问题描述】:

我正在尝试为 caffe 网络打印一些诊断信息,但是虽然我可以找到 blob 输出的数据的形状,但我无法直接找到预期输入数据的形状。例如:

nb = self.net.blobs # nb is an OrderedDict of the blob objects 
                      that make up a VGG16 net
for ctr, name in enumerate(nb):
   print ctr, name, nb[name].data.shape

0 data (10, 3, 224, 224)
1 conv1_1 (10, 64, 224, 224)
2 conv1_2 (10, 64, 224, 224)
3 pool1 (10, 64, 112, 112)
4 conv2_1 (10, 128, 112, 112)
5 conv2_2 (10, 128, 112, 112)
6 pool2 (10, 128, 56, 56)
7 conv3_1 (10, 256, 56, 56)
8 conv3_2 (10, 256, 56, 56)
9 conv3_3 (10, 256, 56, 56)
10 pool3 (10, 256, 28, 28)
11 conv4_1 (10, 512, 28, 28)
12 conv4_2 (10, 512, 28, 28)
13 conv4_3 (10, 512, 28, 28)
14 pool4 (10, 512, 14, 14)
15 conv5_1 (10, 512, 14, 14)
16 conv5_2 (10, 512, 14, 14)
17 conv5_3 (10, 512, 14, 14)
18 pool5 (10, 512, 7, 7)
19 fc6 (10, 4096)
20 fc7 (10, 4096)
21 fc8a (10, 365)
22 prob (10, 365)

如何更改此代码以使输出具有以下形式:

 layer_number  layer_name  input_shape   output_shape  

不直接查询父层以查看它给出的输出?

【问题讨论】:

    标签: machine-learning neural-network deep-learning caffe pycaffe


    【解决方案1】:

    可以修改this answer中的代码,逐层迭代网络:

    def dont_forget_to_thank_me_later(net):
      for li in xrange(len(net.layers)):  # for each layer in the net
      print "{}\t{}\t".format(li, net._layer_names[li]),      
      # for each input to the layer (aka "bottom") print its name and shape
      for bi in list(net._bottom_ids(li)):
        print "{} ({}) ".format(net._blob_names[bi], net.blobs[net._blob_names[bi]].data.shape),
      print "\t"
      # for each output of the layer (aka "top") print its name and shape
      for bi in list(net._top_ids(li)):
        print "{} ({}) ".format(net._blob_names[bi], net.blobs[net._blob_names[bi]].data.shape) 
      print ""  # end of line
    

    请注意,一个层可能有多个输入,或多个输出...

    【讨论】:

    • -谢谢。因此,关键是网络的每一层都有“私有”成员,“_bottom_ids”和“_top_ids”,它们指示哪些 blob 将输入馈送到该层,哪些 blob 从该层传递输出。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-16
    • 2022-01-19
    • 2019-10-11
    • 1970-01-01
    • 2019-02-21
    • 2018-11-18
    • 2016-06-11
    相关资源
    最近更新 更多