From 2f2a10b8a309115f4e6b21a548d5e8d7c1188322 Mon Sep 17 00:00:00 2001 From: zhangxinfeng3 Date: Sun, 13 Dec 2020 14:36:29 +0800 Subject: [PATCH] add checking the threshold of anomaly detection --- mindspore/nn/probability/toolbox/anomaly_detection.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mindspore/nn/probability/toolbox/anomaly_detection.py b/mindspore/nn/probability/toolbox/anomaly_detection.py index 87a635dfc8..ba92269b79 100644 --- a/mindspore/nn/probability/toolbox/anomaly_detection.py +++ b/mindspore/nn/probability/toolbox/anomaly_detection.py @@ -15,6 +15,7 @@ """Toolbox for anomaly detection by using VAE.""" import numpy as np +from mindspore._checkparam import Validator from ..dpn import VAE from ..infer import ELBO, SVI from ...optim import Adam @@ -26,7 +27,7 @@ class VAEAnomalyDetection: Toolbox for anomaly detection by using VAE. Variational Auto-Encoder(VAE) can be used for Unsupervised Anomaly Detection. The anomaly score is the error - between the X and the reconstruction. If the score is high, the X is mostly outlier. + between the X and the reconstruction of X. If the score is high, the X is mostly outlier. Args: encoder(Cell): The Deep Neural Network (DNN) model defined as encoder. @@ -84,6 +85,7 @@ class VAEAnomalyDetection: Returns: Bool, whether the sample is an outlier. """ + threshold = Validator.check_positive_float(threshold) score = self.predict_outlier_score(sample_x) return score >= threshold