MCPcopy Create free account
hub / github.com/pytorch/pytorch / init_weight

Method init_weight

caffe2/python/layers/batch_lr_loss.py:119–166  ·  view source on GitHub ↗
(self, jsd_weight, homotopy_weighting)

Source from the content-addressed store, hash-verified

117 )
118
119 def init_weight(self, jsd_weight, homotopy_weighting):
120 if homotopy_weighting:
121 self.mutex = self.create_param(
122 param_name=('%s_mutex' % self.name),
123 shape=None,
124 initializer=('CreateMutex', ),
125 optimizer=self.model.NoOptim,
126 )
127 self.counter = self.create_param(
128 param_name=('%s_counter' % self.name),
129 shape=[1],
130 initializer=(
131 'ConstantFill', {
132 'value': 0,
133 'dtype': core.DataType.INT64
134 }
135 ),
136 optimizer=self.model.NoOptim,
137 )
138 self.xent_weight = self.create_param(
139 param_name=('%s_xent_weight' % self.name),
140 shape=[1],
141 initializer=(
142 'ConstantFill', {
143 'value': 1.,
144 'dtype': core.DataType.FLOAT
145 }
146 ),
147 optimizer=self.model.NoOptim,
148 )
149 self.jsd_weight = self.create_param(
150 param_name=('%s_jsd_weight' % self.name),
151 shape=[1],
152 initializer=(
153 'ConstantFill', {
154 'value': 0.,
155 'dtype': core.DataType.FLOAT
156 }
157 ),
158 optimizer=self.model.NoOptim,
159 )
160 else:
161 self.jsd_weight = self.model.add_global_constant(
162 '%s_jsd_weight' % self.name, jsd_weight
163 )
164 self.xent_weight = self.model.add_global_constant(
165 '%s_xent_weight' % self.name, 1. - jsd_weight
166 )
167
168 def update_weight(self, net):
169 net.AtomicIter([self.mutex, self.counter], [self.counter])

Callers 1

__init__Method · 0.95

Calls 2

add_global_constantMethod · 0.80
create_paramMethod · 0.45

Tested by

no test coverage detected