paddlets.models.anomaly.dl._anomaly_transformer.encoder

class EncoderLayer(attention: ~typing.Callable[[...], ~paddle.Tensor], d_model: int, d_ff: ~typing.Optional[int] = None, dropout: float = 0.1, activation: ~typing.Callable[[...], ~paddle.Tensor] = <function gelu>)[source]

Bases: Layer

EncoderLayer in anomaly transformer.

Parameters
  • attention (Callable[..., paddle.Tensor]) – The attention in encoderlayer.

  • d_model (int) – The expected feature size for the input of the anomaly transformer.

  • d_ff (int) – The Number of channels for FFN layers.

  • dropout (float) – Dropout regularization parameter.

  • activation (Callable[..., paddle.Tensor]) – The activation function for the EncoderLayer, defalut: F.gelu.

_nn

Dynamic graph LayerList.

Type

paddle.nn.Sequential

forward(x, attn_mask=None) Tensor[source]

Encoder Forward.

Parameters
  • x (paddle.Tensor) – Dict of feature tensor.

  • attn_mask (Callable[..., paddle.Tensor]) – Whether to use mask in encoder.

Returns

Output of EncoderLayer.

Return type

paddle.Tensor

class Encoder(attn_layers, norm_layer=None)[source]

Bases: Layer

Encoder layers in anomaly transformer.

Parameters
  • attn_layers (Callable[..., paddle.Tensor]) – Dict of feature tensor.

  • norm_layer (Callable[..., paddle.Tensor]) – Layernorm in encoder for attention layer.

_nn

Dynamic graph LayerList.

Type

paddle.nn.Sequential

forward(x: Tensor, attn_mask: Optional[Callable[[...], Tensor]] = None) Tensor[source]

Encoder Forward.

Parameters
  • x (paddle.Tensor) – The input of Encoder.

  • attn_mask (Callable[..., paddle.Tensor]) – Whether to use mask in ecoder.

Returns

Output of model.

Return type

paddle.Tensor