如何计算Google Net上的初始模块的感知字段?

时间:2018-04-16 05:37:43

标签: neural-network computer-vision deep-learning caffe conv-neural-network

图片中附有GoogleNet的一个初始模块。 我们如何计算这个初始模块的感受域? 我们可以只计算一个卷积分支吗?

enter image description here

编辑:

我有这个程序用于感受性字段大小计算。

import math
convnet =   [[7,2,3],[1,1,0],[3,2,0],[1,1,0],[1,1,0],[1,1,0],[1,1,0],[3,1,1],[1,1,0],[3,2,0],[1,1,0],[1,1,0],[3,1,1],[1,1,0],[1,1,0],[1,1,0],[3,1,1],[1,1,0],[3,2,0],[1,1,0],[1,1,0],[3,1,1],[1,1,0],[5,3,0],[1,1,0],[1,1,0],[3,1,1],[1,1,0],[1,1,0],[1,1,0],[3,1,1],[1,1,0],[1,1,0],[1,1,0],[3,1,1],[1,1,0],[5,3,0],[1,1,0],[1,1,0],[3,1,1],[1,1,0],[3,2,1],[1,1,0],[1,1,0],[3,1,1],[1,1,0],[1,1,0],[1,1,0],[3,1,1],[1,1,0],[7,1,1]]
layer_names = ["conv1/7x7_s2","conv1/relu_7x7","pool1/3x3_s2","pool1/norm1","conv2/3x3_reduce","conv2/relu_3x3_reduce","conv2/3x3","conv2/relu_3x3","pool2/3x3_s2","inception_3a/3x3_reduce","inception_3a/relu_3x3_reduce","inception_3a/3x3","inception_3a/relu_3x3","inception_3b/3x3_reduce","inception_3b/relu_3x3_reduce","inception_3b/3x3","inception_3b/relu_3x3","pool3/3x3_s2","inception_4a/3x3_reduce","inception_4a/relu_3x3_reduce","inception_4a/3x3","inception_4a/relu_3x3","loss1/ave_pool","inception_4b/3x3_reduce","inception_4b/relu_3x3_reduce","inception_4b/3x3","inception_4b/relu_3x3","inception_4c/3x3_reduce","inception_4c/relu_3x3_reduce","inception_4c/3x3","inception_4c/relu_3x3","inception_4d/3x3_reduce","inception_4d/relu_3x3_reduce","inception_4d/3x3","inception_4d/relu_3x3","loss2/ave_pool","inception_4e/3x3_reduce","inception_4e/relu_3x3_reduce","inception_4e/3x3","inception_4e/relu_3x3","pool4/3x3_s2","inception_5a/3x3_reduce","inception_5a/relu_3x3_reduce","inception_5a/3x3","inception_5a/relu_3x3","inception_5b/3x3_reduce","inception_5b/relu_3x3_reduce","inception_5b/3x3","inception_5b/relu_3x3","pool5/7x7_s1"]
imsize = 720
def outFromIn(isz, layernum, net = convnet):
    if layernum>len(net): layernum=len(net)

    totstride = 1
    insize = isz
    #for layerparams in net:
    for layer in range(layernum):
        fsize, stride, pad = net[layer]
        outsize = (insize - fsize + 2*pad) / stride + 1
        insize = outsize
        totstride = totstride * stride
    return outsize, totstride

def inFromOut( layernum, net = convnet):
    if layernum>len(net): layernum=len(net)
    outsize = 1
    #for layerparams in net:
    for layer in reversed(range(layernum)):
        fsize, stride, pad = net[layer]
        outsize = ((outsize -1)* stride) + fsize
    RFsize = outsize
    return RFsize

if __name__ == '__main__':

    print "layer output sizes given image = %dx%d" % (imsize, imsize)
    for i in range(len(convnet)):
        p = outFromIn(imsize,i+1)
        rf = inFromOut(i+1)
        print "Layer Name = %s, Output size = %3d, Stride = % 3d, RF size = %3d" % (layer_names[i], p[0], p[1], rf)

我设置的图像大小为720. pool5 / 7x7_s1图层的感知字段大小比原始图像大小大得多。这个计算有什么问题?

layer output sizes given image = 224x224
Layer Name = conv1/7x7_s2, Output size = 112, Stride =   2, RF size =   7
Layer Name = conv1/relu_7x7, Output size = 112, Stride =   2, RF size =   7
Layer Name = pool1/3x3_s2, Output size =  55, Stride =   4, RF size =  11
Layer Name = pool1/norm1, Output size =  55, Stride =   4, RF size =  11
Layer Name = conv2/3x3_reduce, Output size =  55, Stride =   4, RF size =  11
Layer Name = conv2/relu_3x3_reduce, Output size =  55, Stride =   4, RF size =  11
Layer Name = conv2/3x3, Output size =  55, Stride =   4, RF size =  19
Layer Name = conv2/relu_3x3, Output size =  55, Stride =   4, RF size =  19
Layer Name = pool2/3x3_s2, Output size =  27, Stride =   8, RF size =  27
Layer Name = inception_3a/3x3_reduce, Output size =  27, Stride =   8, RF size =  27
Layer Name = inception_3a/relu_3x3_reduce, Output size =  27, Stride =   8, RF size =  27
Layer Name = inception_3a/3x3, Output size =  27, Stride =   8, RF size =  43
Layer Name = inception_3a/relu_3x3, Output size =  27, Stride =   8, RF size =  43
Layer Name = inception_3b/3x3_reduce, Output size =  27, Stride =   8, RF size =  43
Layer Name = inception_3b/relu_3x3_reduce, Output size =  27, Stride =   8, RF size =  43
Layer Name = inception_3b/3x3, Output size =  27, Stride =   8, RF size =  59
Layer Name = inception_3b/relu_3x3, Output size =  27, Stride =   8, RF size =  59
Layer Name = pool3/3x3_s2, Output size =  13, Stride =  16, RF size =  75
Layer Name = inception_4a/3x3_reduce, Output size =  13, Stride =  16, RF size =  75
Layer Name = inception_4a/relu_3x3_reduce, Output size =  13, Stride =  16, RF size =  75
Layer Name = inception_4a/3x3, Output size =  13, Stride =  16, RF size = 107
Layer Name = inception_4a/relu_3x3, Output size =  13, Stride =  16, RF size = 107
Layer Name = inception_4b/3x3_reduce, Output size =  13, Stride =  16, RF size = 107
Layer Name = inception_4b/relu_3x3_reduce, Output size =  13, Stride =  16, RF size = 107
Layer Name = inception_4b/3x3, Output size =  13, Stride =  16, RF size = 139
Layer Name = inception_4b/relu_3x3, Output size =  13, Stride =  16, RF size = 139
Layer Name = inception_4c/3x3_reduce, Output size =  13, Stride =  16, RF size = 139
Layer Name = inception_4c/relu_3x3_reduce, Output size =  13, Stride =  16, RF size = 139
Layer Name = inception_4c/3x3, Output size =  13, Stride =  16, RF size = 171
Layer Name = inception_4c/relu_3x3, Output size =  13, Stride =  16, RF size = 171
Layer Name = inception_4d/3x3_reduce, Output size =  13, Stride =  16, RF size = 171
Layer Name = inception_4d/relu_3x3_reduce, Output size =  13, Stride =  16, RF size = 171
Layer Name = inception_4d/3x3, Output size =  13, Stride =  16, RF size = 203
Layer Name = inception_4d/relu_3x3, Output size =  13, Stride =  16, RF size = 203
Layer Name = inception_4e/3x3_reduce, Output size =  13, Stride =  16, RF size = 203
Layer Name = inception_4e/relu_3x3_reduce, Output size =  13, Stride =  16, RF size = 203
Layer Name = inception_4e/3x3, Output size =  13, Stride =  16, RF size = 235
Layer Name = inception_4e/relu_3x3, Output size =  13, Stride =  16, RF size = 235
Layer Name = pool4/3x3_s2, Output size =   7, Stride =  32, RF size = 267
Layer Name = inception_5a/3x3_reduce, Output size =   7, Stride =  32, RF size = 267
Layer Name = inception_5a/relu_3x3_reduce, Output size =   7, Stride =  32, RF size = 267
Layer Name = inception_5a/3x3, Output size =   7, Stride =  32, RF size = 331
Layer Name = inception_5a/relu_3x3, Output size =   7, Stride =  32, RF size = 331
Layer Name = inception_5b/3x3_reduce, Output size =   7, Stride =  32, RF size = 331
Layer Name = inception_5b/relu_3x3_reduce, Output size =   7, Stride =  32, RF size = 331
Layer Name = inception_5b/3x3, Output size =   7, Stride =  32, RF size = 395
Layer Name = inception_5b/relu_3x3, Output size =   7, Stride =  32, RF size = 395
Layer Name = pool5/7x7_s1, Output size =   3, Stride =  32, RF size = 587

1 个答案:

答案 0 :(得分:0)

您应该计算每条路径(您有四条路径),然后选择最大的接收区域。