首页 > 代码库 > 如何计算卷积神经网络中接受野尺寸

如何计算卷积神经网络中接受野尺寸

 

由于在word中编辑,可能有公式、visio对象等,所以选择截图方式……

技术分享

技术分享

技术分享

技术分享

技术分享

计算接受野的Python代码:

Python代码来源http://stackoverflow.com/questions/35582521/how-to-calculate-receptive-field-size

#Compute input size that leads to a 1x1 output size, among other things   # [filter size, stride, padding]convnet =[[11,4,0],[3,2,0],[5,1,2],[3,2,0],[3,1,1],[3,1,1],[3,1,1],[3,2,0],[6,1,0]]layer_name = [‘conv1‘,‘pool1‘,‘conv2‘,‘pool2‘,‘conv3‘,‘conv4‘,‘conv5‘,‘pool5‘,‘fc6-conv‘]imsize = 227def outFromIn(isz, layernum = 9, 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, totstridedef inFromOut( layernum = 9, 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 RFsizeif __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_name[i], p[0], p[1], rf)

  

 

如何计算卷积神经网络中接受野尺寸