MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / reduce_weighted_loss

Function reduce_weighted_loss

tensorflow/python/keras/utils/losses_utils.py:58–67  ·  view source on GitHub ↗

Reduces the individual weighted loss measurements.

(weighted_losses,
                         reduction=ReductionV2.SUM_OVER_BATCH_SIZE)

Source from the content-addressed store, hash-verified

56
57
58def reduce_weighted_loss(weighted_losses,
59 reduction=ReductionV2.SUM_OVER_BATCH_SIZE):
60 """Reduces the individual weighted loss measurements."""
61 if reduction == ReductionV2.NONE:
62 loss = weighted_losses
63 else:
64 loss = math_ops.reduce_sum(weighted_losses)
65 if reduction == ReductionV2.SUM_OVER_BATCH_SIZE:
66 loss = _safe_mean(loss, _num_elements(weighted_losses))
67 return loss
68
69
70def compute_weighted_loss(losses,

Callers 1

compute_weighted_lossFunction · 0.85

Calls 3

reduce_sumMethod · 0.80
_safe_meanFunction · 0.70
_num_elementsFunction · 0.70

Tested by

no test coverage detected