Function
reduced_loss_fn
(*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
Tested by
no test coverage detected