MCPcopy
hub / github.com/open-mmlab/mmdetection / convert_bn

Function convert_bn

tools/model_converters/detectron2pytorch.py:11–21  ·  view source on GitHub ↗
(blobs, state_dict, caffe_name, torch_name, converted_names)

Source from the content-addressed store, hash-verified

9
10
11def convert_bn(blobs, state_dict, caffe_name, torch_name, converted_names):
12 # detectron replace bn with affine channel layer
13 state_dict[torch_name + '.bias'] = torch.from_numpy(blobs[caffe_name +
14 '_b'])
15 state_dict[torch_name + '.weight'] = torch.from_numpy(blobs[caffe_name +
16 '_s'])
17 bn_size = state_dict[torch_name + '.weight'].size()
18 state_dict[torch_name + '.running_mean'] = torch.zeros(bn_size)
19 state_dict[torch_name + '.running_var'] = torch.ones(bn_size)
20 converted_names.add(caffe_name + '_b')
21 converted_names.add(caffe_name + '_s')
22
23
24def convert_conv_fc(blobs, state_dict, caffe_name, torch_name,

Callers 1

convertFunction · 0.85

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected