def compute(self): _prediction_tensor = torch.cat(self._predictions, dim=0) _target_tensor = torch.cat(self._targets, dim=0) if dist.is_available() and dist.is_initialized( ) and not self._is_reduced: _prediction_tensor = all_gather(_prediction_tensor) _target_tensor = all_gather(_target_tensor) self._is_reduced = True return compute_confusion_matrix( y_pred=_prediction_tensor, y=_target_tensor, to_onehot_y=self.to_onehot_y, activation=self.activation, bin_mode=self.bin_mode, bin_threshold=self.bin_threshold, metric_name=self.metric_name, average=self.average, zero_division=self.zero_division, )
def test_value(self, input_data, expected_value): result = compute_confusion_matrix(**input_data) self.assertEqual(expected_value, result)
def test_value(self, input_data, expected_value): result = compute_confusion_matrix(**input_data) np.testing.assert_allclose(expected_value, result, rtol=1e-7)