!8487 Optimize the uncertainty output value

From: @zhangxinfeng3
Reviewed-by: @zichun_ye,@wang_zi_dong
Signed-off-by: @wang_zi_dong
pull/8487/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit f34c8a45c5

@ -103,10 +103,6 @@ class UncertaintyEvaluation:
raise ValueError("If save_model is True, the epi_uncer_model_path and " raise ValueError("If save_model is True, the epi_uncer_model_path and "
"ale_uncer_model_path should not be None.") "ale_uncer_model_path should not be None.")
def _uncertainty_normalize(self, data):
area = np.max(data) - np.min(data)
return (data - np.min(data)) / area
def _get_epistemic_uncertainty_model(self): def _get_epistemic_uncertainty_model(self):
""" """
Get the model which can obtain the epistemic uncertainty. Get the model which can obtain the epistemic uncertainty.
@ -150,7 +146,7 @@ class UncertaintyEvaluation:
else: else:
outputs = np.stack(outputs, axis=1) outputs = np.stack(outputs, axis=1)
epi_uncertainty = outputs.var(axis=1) epi_uncertainty = outputs.var(axis=1)
epi_uncertainty = self._uncertainty_normalize(np.array(epi_uncertainty)) epi_uncertainty = np.array(epi_uncertainty)
return epi_uncertainty return epi_uncertainty
def _get_aleatoric_uncertainty_model(self): def _get_aleatoric_uncertainty_model(self):
@ -184,7 +180,7 @@ class UncertaintyEvaluation:
self._get_aleatoric_uncertainty_model() self._get_aleatoric_uncertainty_model()
_, var = self.ale_uncer_model(eval_data) _, var = self.ale_uncer_model(eval_data)
ale_uncertainty = self.sum(self.pow(var, 2), 1) ale_uncertainty = self.sum(self.pow(var, 2), 1)
ale_uncertainty = self._uncertainty_normalize(ale_uncertainty.asnumpy()) ale_uncertainty = ale_uncertainty.asnumpy()
return ale_uncertainty return ale_uncertainty
def eval_epistemic_uncertainty(self, eval_data): def eval_epistemic_uncertainty(self, eval_data):

Loading…
Cancel
Save