如何计算卷积神经网络中接受野尺寸
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何计算卷积神经网络中接受野尺寸相关的知识,希望对你有一定的参考价值。
由于在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 = 227 def 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, totstride def 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 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_name[i], p[0], p[1], rf)
以上是关于如何计算卷积神经网络中接受野尺寸的主要内容,如果未能解决你的问题,请参考以下文章