MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / _normalize_probabilities

Method _normalize_probabilities

monai/transforms/compose.py:481–490  ·  view source on GitHub ↗
(self, weights)

Source from the content-addressed store, hash-verified

479 self.log_stats = log_stats
480
481 def _normalize_probabilities(self, weights):
482 if len(weights) == 0:
483 return weights
484 weights = np.array(weights)
485 if np.any(weights < 0):
486 raise ValueError(f"Probabilities must be greater than or equal to zero, got {weights}.")
487 if np.all(weights == 0):
488 raise ValueError(f"At least one probability must be greater than zero, got {weights}.")
489 weights = weights / weights.sum()
490 return list(weights)
491
492 def flatten(self):
493 transforms = []

Callers 1

__init__Method · 0.95

Calls 1

arrayMethod · 0.80

Tested by

no test coverage detected