MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / train

Function train

imperative/python/test/integration/test_dp_correctness.py:83–90  ·  view source on GitHub ↗
(data, label, net, opt, gm)

Source from the content-addressed store, hash-verified

81
82
83def train(data, label, net, opt, gm):
84 opt.clear_grad()
85 with gm:
86 pred = net(data)
87 loss = F.nn.cross_entropy(pred, label)
88 gm.backward(loss)
89 opt.step()
90 return loss
91
92
93def update_model(model_path):

Callers 2

update_modelFunction · 0.70
workerFunction · 0.70

Calls 3

clear_gradMethod · 0.45
backwardMethod · 0.45
stepMethod · 0.45

Tested by

no test coverage detected