# Source code for mindspore.nn.probability.toolbox.anomaly_detection

# Copyright 2020 Huawei Technologies Co., Ltd
#
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# Unless required by applicable law or agreed to in writing, software
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# ============================================================================
"""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
[docs]class VAEAnomalyDetection: r""" 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 of X. If the score is high, the X is mostly outlier. Args: encoder(Cell): The Deep Neural Network (DNN) model defined as encoder. decoder(Cell): The DNN model defined as decoder. hidden_size(int): The size of encoder's output tensor. latent_size(int): The size of the latent space. Supported Platforms: Ascend GPU """ def __init__(self, encoder, decoder, hidden_size=400, latent_size=20): self.vae = VAE(encoder, decoder, hidden_size, latent_size)