paddlets.models.anomaly.dl.usad
USAD模型是2020年提出的基于自编码器, 同时利用对抗训练的无监督多时序异常检测学习方法 USAD : UnSupervised Anomaly Detection on Multivariate Time Series .
- 模型特性
基于对抗网络训练的AE模型
- class USAD(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.activation.Sigmoid'>, 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, flatten: bool = True)[源代码]
-
USAD 异常检测模型
- 参数
in_chunk_len (int) – 模型输入的时间序列长度。
sampling_stride (int) – 相邻样本间的采样间隔。
loss_fn (Callable[..., paddle.Tensor]) – 损失函数。
optimizer_fn (Callable[..., Optimizer]) – 优化器算法。
threshold_fn (Callable[..., float]|None) – 获取异常阈值的方法。
q (float) – 用于计算异常的比例,0-100之间的百分比
threshold (float|None) – 判断异常的阈值。
anomaly_score_fn (Callable[..., List[float]]|None) – 获取异常分数的方法。
pred_adjust (bool) – 是否基于真实值去调整预测值
pred_adjust_fn (Callable[..., np.ndarray]|None) – 调整预测数值的方法
optimizer_params (Dict[str, Any]) – 优化器参数。
eval_metrics (List[str]) – 模型的评估指标。
callbacks (List[Callback]) – 自定义的callback函数。
batch_size (int) – 单个batch中的样本数量。
max_epochs (int) – 最大允许的训练epoch数。
verbose (int) – 模型日志模式。
patience (int) – 模型训练过程中, 当评估指标超过一定轮数不再变优,模型提前停止训练。
seed (int|None) – 全局随机种子,注: 保证每次模型参数初始化一致。
ed_type (str) – 编码器和解码器的类型,目前支持MLP和CNN。
activation (Callable[..., paddle.Tensor]) – 隐层的激活函数。
last_layer_activation (Callable[..., paddle.Tensor]) – 最后一层的激活函数。
hidden_config (List[int]|None) – 列表第i个元素表示第i层神经元的个数(MLP)或者输出通道数(CNN)。
kernel_size (int) – 卷积核的大小。
dropout_rate (float) – 神经元丢弃的比例。
use_bn (bool) – 是否开启batch normalization。
embedding_size (int) – emb向量的维度
pooling – 在emb汇聚时是否使用平均池化,如果是False,直接对emb做concat连接
flatten (bool) – 是否对in_chunk_len以及feature_dim维度进行打平
- _in_chunk_len
模型输入的时间序列长度。
- Type
int
- _sampling_stride
相邻样本间的采样间隔。
- Type
int
- _loss_fn
损失函数。
- Type
Callable[…, paddle.Tensor]
- _optimizer_fn
优化器算法。
- Type
Callable[…, Optimizer]
- _threshold_fn
获取异常阈值的方法。
- Type
Callable[…, float]|None)
- _q
用于计算异常的比例,0-100之间的百分比
- Type
float
- _threshold
判断异常的阈值。
- Type
float|None
- _anomaly_score_fn
获取异常分数的方法。
- Type
Callable[…, List[float]]|None
- _pred_adjust
是否基于真实值去调整预测值
- Type
bool
- _pred_adjust_fn
调整预测数值的方法
- Type
Callable[…, np.ndarray]|None
- _optimizer_params
优化器参数。
- Type
Dict[str, Any]
- _eval_metrics
模型的评估指标。
- Type
List[str]
- _batch_size
单个batch中的样本数量。
- Type
int
- _max_epochs
最大允许的训练epoch数。
- Type
int
- _verbose
模型日志模式。
- Type
int
- _patience
模型训练过程中, 当评估指标超过一定轮数不再变优,模型提前停止训练。
- Type
int
- _seed
全局随机种子,注: 保证每次模型参数初始化一致。
- Type
int|None
- _stop_training
Training status.
- Type
bool
- _ed_type
编码器和解码器的类型,目前支持MLP和CNN。
- Type
str
- _activation
隐层的激活函数。
- Type
Callable[…, paddle.Tensor]
- _last_layer_activation
最后一层的激活函数。
- Type
Callable[…, paddle.Tensor]
列表第i个元素表示第i层神经元的个数(MLP)或者输出通道数(CNN)。
- Type
List[int]|None
- _kernel_size
卷积核的大小。
- Type
int
- _dropout_rate
神经元丢弃的比例。
- Type
float
- _use_bn
是否开启batch normalization。
- Type
bool
- _embedding_size
emb向量的维度
- Type
int
- _pooling
在emb汇聚时是否使用平均池化,如果是False,直接对emb做concat连接
- Type
bool
- _flatten
是否对in_chunk_len以及feature_dim维度进行打平
- Type
bool