paddlets.models.anomaly.dl.autoencoder

class AutoEncoder(in_chunk_len: int, sampling_stride: int = 1, loss_fn: ~typing.Callable[[...], ~paddle.Tensor] = <function mse_loss>, optimizer_fn: ~typing.Callable[[...], ~paddle.optimizer.optimizer.Optimizer] = <class 'paddle.optimizer.adam.Adam'>, threshold_fn: ~typing.Callable[[...], float] = <function percentile>, q: float = 100, 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.001}, 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, ed_type: str = 'MLP', activation: ~typing.Callable[[...], ~paddle.Tensor] = <class 'paddle.nn.layer.activation.ReLU'>, last_layer_activation: ~typing.Callable[[...], ~paddle.Tensor] = <class 'paddle.nn.layer.common.Identity'>, use_bn: bool = False, hidden_config: ~typing.Optional[~typing.List[int]] = None, kernel_size: int = 3, dropout_rate: float = 0.2, embedding_size: int = 16, pooling: bool = False)[source]

Bases: AnomalyBaseModel

Auto encoder 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.

  • q (float) – The parameter used to calculate the quantile which range is [0, 100].

  • 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.

  • ed_type (str) – The type of encoder and decoder.

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

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

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

  • kernel_size (int) – Kernel size for Conv1D.

  • dropout_rate (float) – Dropout regularization parameter.

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

  • embedding_size (int) – The size of each embedding vector.

  • pooling – Whether to use average pooling to aggregate embeddings, if False, concat each embedding.

_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)

_q

The parameter used to calculate the quantile which range is [0, 100].

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

_ed_type

The type of encoder and decoder.

Type

str

_activation

The activation function for the hidden layers.

Type

Callable[…, paddle.Tensor]

_last_layer_activation

The activation function for the last layer.

Type

Callable[…, paddle.Tensor]

_hidden_config

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

Type

List[int]|None

_kernel_size

Kernel size for Conv1D.

Type

int

_dropout_rate

Dropout regularization parameter.

Type

float

_use_bn

Whether to use batch normalization.

Type

bool

_embedding_size

The size of each embedding vector.

Type

int

_pooling

Whether to use average pooling to aggregate embeddings, if False, concat each embedding.

Type

bool