MCPcopy Create free account
hub / github.com/BorealisAI/scaleformer / _init_weights

Function _init_weights

models/NHits.py:277–292  ·  view source on GitHub ↗
(module, initialization)

Source from the content-addressed store, hash-verified

275
276# Cell
277def _init_weights(module, initialization):
278 if type(module) == t.nn.Linear:
279 if initialization == 'orthogonal':
280 t.nn.init.orthogonal_(module.weight)
281 elif initialization == 'he_uniform':
282 t.nn.init.kaiming_uniform_(module.weight)
283 elif initialization == 'he_normal':
284 t.nn.init.kaiming_normal_(module.weight)
285 elif initialization == 'glorot_uniform':
286 t.nn.init.xavier_uniform_(module.weight)
287 elif initialization == 'glorot_normal':
288 t.nn.init.xavier_normal_(module.weight)
289 elif initialization == 'lecun_normal':
290 pass #t.nn.init.normal_(module.weight, 0.0, std=1/np.sqrt(module.weight.numel()))
291 else:
292 assert 1<0, f'Initialization {initialization} not found'
293
294# Cell
295ACTIVATIONS = ['ReLU',

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected