MCPcopy Create free account
hub / github.com/QWTforGithub/T2LDM / mean

Function mean

utils/common.py:676–692  ·  view source on GitHub ↗

Nan-mean compatible with generators.

(values, ignore_nan=False, empty=0)

Source from the content-addressed store, hash-verified

674
675
676def mean(values, ignore_nan=False, empty=0):
677 """Nan-mean compatible with generators."""
678 values = iter(values)
679 if ignore_nan:
680 values = filterfalse(isnan, values)
681 try:
682 n = 1
683 acc = next(values)
684 except StopIteration:
685 if empty == "raise":
686 raise ValueError("Empty mean")
687 return empty
688 for n, v in enumerate(values, 2):
689 acc += v
690 if n == 1:
691 return acc
692 return acc / n
693
694
695class LovaszLoss(_Loss):

Callers 3

_lovasz_hingeFunction · 0.85
_lovasz_softmaxFunction · 0.85
_lovasz_softmax_flatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected