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

Function train_func

imperative/python/test/integration/test_bn.py:165–171  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

163 opt = optimizer.SGD(net.parameters(), 1e-3)
164
165 def train_func(x):
166 with gm:
167 y = net(x)
168 loss = y.mean()
169 gm.backward(loss)
170 opt.step().clear_grad()
171 return loss
172
173 if trace_mode is not None:
174 train_func = trace(train_func, symbolic=trace_mode)

Callers 1

run_syncbnFunction · 0.70

Calls 4

meanMethod · 0.45
backwardMethod · 0.45
clear_gradMethod · 0.45
stepMethod · 0.45

Tested by

no test coverage detected