MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / proc_scale

Method proc_scale

tensorpack/utils/loadcaffe.py:78–93  ·  view source on GitHub ↗
(self, idx, name, param)

Source from the content-addressed store, hash-verified

76 name + '/variance/EMA': param[1].data / scale_factor}
77
78 def proc_scale(self, idx, name, param):
79 bottom_name = self.net.bottom_names[name][0]
80 # find the bn layer before this scaling
81 for i, layer in enumerate(self.net.layers):
82 if layer.type == 'BatchNorm':
83 name2 = self.layer_names[i]
84 bottom_name2 = self.net.bottom_names[name2][0]
85 if bottom_name2 == bottom_name:
86 # scaling and BN share the same bottom, should merge
87 logger.info("Merge {} and {} into one BatchNorm layer".format(
88 name, name2))
89 return {name2 + '/beta': param[1].data,
90 name2 + '/gamma': param[0].data}
91 # assume this scaling layer is part of some BN
92 logger.error("Could not find a BN layer corresponding to this Scale layer!")
93 raise ValueError()
94
95
96def load_caffe(model_desc, model_file):

Callers

nothing calls this directly

Calls 1

formatMethod · 0.80

Tested by

no test coverage detected