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

Function train_func

imperative/python/test/integration/test_optimizer.py:80–86  ·  view source on GitHub ↗
(data, *, opt=None, gm=None)

Source from the content-addressed store, hash-verified

78
79 @trace(symbolic=symbolic)
80 def train_func(data, *, opt=None, gm=None):
81 opt.clear_grad()
82 with gm:
83 pred = net(data)
84 loss = pred.sum()
85 gm.backward(loss)
86 opt.step()
87
88 # reset net and opt
89 net = Simple()

Callers 1

_test_optimizerFunction · 0.70

Calls 4

clear_gradMethod · 0.45
sumMethod · 0.45
backwardMethod · 0.45
stepMethod · 0.45

Tested by

no test coverage detected