MCPcopy Create free account
hub / github.com/649453932/Chinese-Text-Classification-Pytorch / init_network

Function init_network

train_eval.py:13–26  ·  view source on GitHub ↗
(model, method='xavier', exclude='embedding', seed=123)

Source from the content-addressed store, hash-verified

11
12# 权重初始化,默认xavier
13def init_network(model, method='xavier', exclude='embedding', seed=123):
14 for name, w in model.named_parameters():
15 if exclude not in name:
16 if 'weight' in name:
17 if method == 'xavier':
18 nn.init.xavier_normal_(w)
19 elif method == 'kaiming':
20 nn.init.kaiming_normal_(w)
21 else:
22 nn.init.normal_(w)
23 elif 'bias' in name:
24 nn.init.constant_(w, 0)
25 else:
26 pass
27
28
29def train(config, model, train_iter, dev_iter, test_iter):

Callers 1

run.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected