MCPcopy Create free account
hub / github.com/alinlab/SelfPatch / _init_weights

Method _init_weights

selfpatch_vision_transformer.py:291–298  ·  view source on GitHub ↗
(self, m)

Source from the content-addressed store, hash-verified

289 self.apply(self._init_weights)
290
291 def _init_weights(self, m):
292 if isinstance(m, nn.Linear):
293 trunc_normal_(m.weight, std=.02)
294 if isinstance(m, nn.Linear) and m.bias is not None:
295 nn.init.constant_(m.bias, 0)
296 elif isinstance(m, nn.LayerNorm):
297 nn.init.constant_(m.bias, 0)
298 nn.init.constant_(m.weight, 1.0)
299
300 def interpolate_pos_encoding(self, x, w, h):
301 npatch = x.shape[1]

Callers

nothing calls this directly

Calls 1

trunc_normal_Function · 0.90

Tested by

no test coverage detected