如何确定 caffe blob 的输入维度
How can I determine the input dimensions for a caffe blob
我正在尝试为咖啡网络打印出一些诊断信息,但虽然我可以找到 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
不直接查询父层看它给出什么输出?
可以修改中的代码,逐层迭代网络:
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
请注意,一个层可能有多个输入,或多个输出...
我正在尝试为咖啡网络打印出一些诊断信息,但虽然我可以找到 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
不直接查询父层看它给出什么输出?
可以修改
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
请注意,一个层可能有多个输入,或多个输出...