@property
def mode(self):
if self.length == 0:
raise RuntimeError("Empirical distribution instance is empty.")
if self._uniform_weights:
print(colored("Warning: weights are uniform and there is no unique mode.", "red", attrs=["bold"]))
if self._mode is None:
if self.sorted_by_weights:
self._mode = self.values[0]
else:
_, max_index = self.weights.max(-1)
self._mode = self.values[int(max_index)]
return self._mode
@property
After Change
return self._variance
@property
def mode(self):
self._check_finalized()
// if self._uniform_weights:
// print(colored("Warning: weights are uniform and there is no unique mode.", "red", attrs=["bold"]))
if self._mode is None:
_, max_index = util.to_tensor(self._log_weights).max(-1)
self._mode = self._get_value(int(max_index))
return self._mode