def construc_net(widening_factor, num_block_per_stage):
net = caffe.NetSpec()
net.data = L.Input(input_param = dict(shape = dict(dim = [1,3,32,32])))
net.conv1 = L.Convolution(net.data, num_output = 16,
kernel_size = 3, stride = 1, pad = 1,
bias_term = False)
# stage 1
num_out = widening_factor * 16
block_pre = _block('2_1', net, net.conv1, num_out, has_branch1=True, increasing_dims=False)
for idx in xrange(2,num_block_per_stage+1,1):
flag = '2_{}'.format(idx)
block_pre = _block(flag, net, block_pre, num_out)
# stage 2
num_out = widening_factor * 32
block_pre = _block('3_1', net, block_pre, num_out, has_branch1=True)
for idx in xrange(2,num_block_per_stage+1,1):
flag = '3_{}'.format(idx)
block_pre = _block(flag, net, block_pre, num_out)
# stage 3
num_out = widening_factor * 64
block_pre = _block('4_1', net, block_pre, num_out, has_branch1=True)
for idx in xrange(2,num_block_per_stage+1,1):
flag = '4_{}'.format(idx)
block_pre = _block(flag, net, block_pre, num_out)
net.bn5 = L.BatchNorm(block_pre)
net.scale5 = L.Scale(net.bn5, bias_term = True, in_place=True)
net.relu5 = L.ReLU(net.scale5, in_place = True)
net.pool5 = L.Pooling(net.relu5, pool = P.Pooling.AVE, global_pooling=True)
net.fc6 = L.InnerProduct(net.pool5, num_output = 10)
net.prob = L.Softmax(net.fc6)
return net.to_proto()
评论列表
文章目录