paddlets.models.anomaly.dl.vae

class stack(in_chunk_dim: int, hidden_config: ~typing.List[int], feature_dim: int, is_encoder: bool = True, base_nn: str = 'MLP', use_bn: bool = True, use_drop: bool = True, dropout_rate: float = 0.5, kernel_size: int = 1, rnn_num_layers: int = 1, direction: str = 'forward', activation: ~typing.Callable[[...], ~paddle.Tensor] = <class 'paddle.nn.layer.activation.ReLU6'>, last_layer_activation: ~typing.Callable[[...], ~paddle.Tensor] = <class 'paddle.nn.layer.activation.ReLU6'>)[source]

Bases: Layer

stack structure.

Parameters
  • in_chunk_dim (int) – The size of the loopback window, i.e. the number of time steps feed to the model.

  • hidden_config (List[int]) – The ith element represents the number of neurons in the ith hidden layer.

  • feature_dim (int) – The numer of feature.

  • is_encoder (bool) – Encoder or Decoder.

  • base_nn (str) – base network for stack.

  • use_bn (bool) – Whether to use batch normalization.

  • use_drop (bool) – Whether to use dropout.

  • dropout_rate (float) – probability of an element to be zeroed.

  • kernel_size (int) – Size of the convolving kernel.

  • rnn_num_layers (int) – Number of recurrent layers.

  • direction (str) – If True, becomes a bidirectional LSTM. Default: False.

  • activation (Callable[..., paddle.Tensor]) – The activation function for the hidden layers.

  • last_layer_activation (Callable[..., paddle.Tensor]) – The activation function for the last layers.

_nn

Dynamic graph LayerList.

Type

paddle.nn.Sequential

forward(x)[source]

Defines the computation performed at every call. Should be overridden by all subclasses.

Parameters
  • *inputs (tuple) – unpacked tuple arguments

  • **kwargs (dict) – unpacked dict arguments

class VAE(in_chunk_len: int, sampling_stride: int = 1, loss_fn: ~typing.Callable[[...], ~paddle.Tensor] = <function smooth_l1_loss_vae>, optimizer_fn: ~typing.Callable[[...], ~paddle.optimizer.optimizer.Optimizer] = <class 'paddle.optimizer.adam.Adam'>, threshold_fn: ~typing.Callable[[...], float] = <function percentile>, threshold: ~typing.Optional[float] = None, threshold_coeff: float = 1.0, anomaly_score_fn: ~typing.Optional[~typing.Callable[[...], ~typing.List[float]]] = None, pred_adjust: bool = False, pred_adjust_fn: ~typing.Callable[[...], ~numpy.ndarray] = <function result_adjust>, optimizer_params: ~typing.Dict[str, ~typing.Any] = {'learning_rate': 0.0001}, eval_metrics: ~typing.List[str] = [], callbacks: ~typing.List[~paddlets.models.common.callbacks.callbacks.Callback] = [], batch_size: int = 32, max_epochs: int = 100, verbose: int = 1, patience: int = 10, seed: ~typing.Union[None, int] = None, hidden_config: ~typing.List[int] = [32, 16], base_en: str = 'MLP', base_de: str = 'MLP', use_bn: bool = True, use_drop: bool = True, dropout_rate: float = 0.5, kernel_size: int = 1, rnn_num_layers: int = 1, direction: str = 'forward', activation: ~typing.Callable[[...], ~paddle.Tensor] = <class 'paddle.nn.layer.activation.ReLU6'>, last_layer_activation: ~typing.Callable[[...], ~paddle.Tensor] = <class 'paddle.nn.layer.activation.ReLU6'>, stdev: float = 0.1)[source]

Bases: AnomalyBaseModel

VAE network for anomaly detection.

Parameters
  • in_chunk_len (int) – The size of the loopback window, i.e. the number of time steps feed to the model.

  • sampling_stride (int) – Sampling intervals between two adjacent samples.

  • loss_fn (Callable[..., paddle.Tensor]) – Loss function.

  • optimizer_fn (Callable[..., Optimizer]) – Optimizer algorithm.

  • threshold_fn (Callable[..., float]|None) – The method to get anomaly threshold.

  • threshold_coeff (float) – The coefficient of threshold.

  • threshold (float|None) – The threshold to judge anomaly.

  • anomaly_score_fn (Callable[..., List[float]]|None) – The method to get anomaly score.

  • pred_adjust (bool) – Whether to adjust the pred label according to the real label.

  • pred_adjust_fn (Callable[..., np.ndarray]|None) – The method to adjust pred label.

  • optimizer_params (Dict[str, Any]) – Optimizer parameters.

  • eval_metrics (List[str]) – Evaluation metrics of model.

  • callbacks (List[Callback]) – Customized callback functions.

  • batch_size (int) – Number of samples per batch.

  • max_epochs (int) – Max epochs during training.

  • verbose (int) – Verbosity mode.

  • patience (int) – Number of epochs to wait for improvement before terminating.

  • seed (int|None) – Global random seed.

  • hidden_config (List[int]|None) – The ith element represents the number of neurons in the ith hidden layer.

  • base_en (str) – The type of encoder.

  • base_de (str) – The type of decoder.

  • use_bn – Whether to use batch normalization.

  • use_drop – Whether to use dropout.

  • dropout_rate (float) – probability of an element to be zeroed.

  • kernel_size (int) – Size of the convolving kernel.

  • rnn_num_layers (int) – Number of recurrent layers.

  • direction (str) – If True, becomes a bidirectional LSTM. Default: False.

  • activation (Callable[..., paddle.Tensor]) – The activation function for the hidden layers.

  • last_layer_activation (Callable[..., paddle.Tensor]) – The activation function for the last layers.

  • stdev (int) – param for reparameterize.

_in_chunk_len

The size of the loopback window, i.e. the number of time steps feed to the model.

Type

int

_sampling_stride

Sampling intervals between two adjacent samples.

Type

int

_loss_fn

Loss function.

Type

Callable[…, paddle.Tensor]

_optimizer_fn

Optimizer algorithm.

Type

Callable[…, Optimizer]

_threshold_fn

The method to get anomaly threshold.

Type

Callable[…, float]|None

_threshold_coeff

The coefficient of threshold.

Type

float

_threshold

The threshold to judge anomaly.

Type

float|None

_anomaly_score_fn

The method to get anomaly score.

Type

Callable[…, List[float]]|None

_pred_adjust

Whether to adjust the pred label according to the real label.

Type

bool

_pred_adjust_fn

The method to adjust pred label.

Type

Callable[…, np.ndarray]|None

_optimizer_params

Optimizer parameters.

Type

Dict[str, Any]

_eval_metrics

Evaluation metrics of model.

Type

List[str]

_callbacks

Customized callback functions.

Type

List[Callback]

_batch_size

Number of samples per batch.

Type

int

_max_epochs

Max epochs during training.

Type

int

_verbose

Verbosity mode.

Type

int

_patience

Number of epochs to wait for improvement before terminating.

Type

int

_seed

Global random seed.

Type

int|None

_stop_training

Training status.

Type

bool

_hidden_config

The ith element represents the number of neurons in the ith hidden layer.

Type

List[int]|None

_base_en

The type of encoder.

Type

str

_base_de

The type of decoder.

Type

str

_use_bn

Whether to use batch normalization.

Type

bool

_use_drop

Whether to use dropout.

Type

bool

_dropout_rate

probability of an element to be zeroed.

Type

float

_kernel_size

Size of the convolving kernel.

Type

int

_rnn_num_layers

Number of recurrent layers.

Type

int

_direction

If True, becomes a bidirectional LSTM. Default: False.

Type

str

_activation

The activation function for the hidden layers.

Type

Callable[…, paddle.Tensor]

_last_layer_activation

The activation function for the last layers.

Type

Callable[…, paddle.Tensor]

_stdev

param for reparameterize.

Type

int