首页 > 代码库 > 如何计算卷积神经网络中接受野尺寸
如何计算卷积神经网络中接受野尺寸
由于在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)
如何计算卷积神经网络中接受野尺寸
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。