def add_batchnormscale(self, input, name):
if True: # necessary?
batch_norm_param = {'moving_average_fraction': 0.95, 'use_global_stats': True}
param = [dict(lr_mult=0), dict(lr_mult=0), dict(lr_mult=0)]
l = L.BatchNorm(input, name=name + '_bn', batch_norm_param=batch_norm_param, param=param, include={'phase': caffe.TEST}, ntop=1)
setattr(self.net_spec, name + '_bn', l)
batch_norm_param = {'moving_average_fraction': 0.95, 'use_global_stats': False}
l = L.BatchNorm(input, name=name + '_bn', top=name + '_bn', batch_norm_param=batch_norm_param, param=param, include={'phase': caffe.TRAIN}, ntop=0)
setattr(self.net_spec, name + '_bn' + '_train', l)
l = L.Scale(getattr(self.net_spec, name + '_bn'), scale_param={'bias_term': True})
setattr(self.net_spec, name, l)
else: # here without split in use_global_stats True/False
l = L.Scale(L.BatchNorm(input), scale_param={'bias_term': True})
setattr(self.net_spec, name, l)
return l
评论列表
文章目录