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

Function reduced_loss_fn

imperative/python/megengine/functional/loss.py:26–33  ·  view source on GitHub ↗
(*args, reduction="mean", **kwargs)

Source from the content-addressed store, hash-verified

24
25 @functools.wraps(loss_fn)
26 def reduced_loss_fn(*args, reduction="mean", **kwargs):
27 loss = loss_fn(*args, **kwargs)
28 if reduction == "none":
29 return loss
30 elif reduction in ("mean", "sum"):
31 return _reduce(reduction)(loss)
32 else:
33 raise ValueError("{} is not a valid value for reduction".format(reduction))
34
35 return reduced_loss_fn
36

Callers

nothing calls this directly

Calls 2

_reduceFunction · 0.50
formatMethod · 0.45

Tested by

no test coverage detected