timesead.models.generative.donut ================================ .. py:module:: timesead.models.generative.donut Classes ------- .. autoapisummary:: timesead.models.generative.donut.Donut timesead.models.generative.donut.MaskedVAELoss timesead.models.generative.donut.DonutAnomalyDetector Module Contents --------------- .. py:class:: Donut(input_dim: int, hidden_dims: List[int] = [100, 100], latent_dim: int = 20, mask_prob: float = 0.01) Bases: :py:obj:`timesead.models.BaseModel` Base class for all neural network modules. Your models should also subclass this class. Modules can also contain other Modules, allowing them to be nested in a tree structure. You can assign the submodules as regular attributes:: import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self) -> None: super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x)) Submodules assigned in this way will be registered, and will also have their parameters converted when you call :meth:`to`, etc. .. note:: As per the example above, an ``__init__()`` call to the parent class must be made before assignment on the child. :ivar training: Boolean represents whether this module is in training or evaluation mode. :vartype training: bool Xu2018 :param input_dim: Should be window_size * features :param hidden_dims: :param latent_dim: .. py:attribute:: latent_dim :value: 20 .. py:attribute:: mask_prob :value: 0.01 .. py:attribute:: vae .. py:method:: forward(inputs: Tuple[torch.Tensor]) -> Tuple[torch.Tensor, Ellipsis] .. py:class:: MaskedVAELoss(size_average=None, reduce=None, reduction: str = 'mean') Bases: :py:obj:`timesead.models.common.VAELoss` .. py:method:: forward(predictions: Tuple[torch.Tensor, Ellipsis], targets: Tuple[torch.Tensor, Ellipsis], *args, **kwargs) -> torch.Tensor .. py:class:: DonutAnomalyDetector(model: Donut, num_mc_samples: int = 1024) Bases: :py:obj:`timesead.models.common.AnomalyDetector` We decided not to include the reconstruction step from the paper here, since we don't have missing data. :param model: :param num_mc_samples: .. py:attribute:: model .. py:attribute:: num_mc_samples :value: 1024 .. py:method:: compute_online_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) -> torch.Tensor .. py:method:: compute_offline_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) -> torch.Tensor .. py:method:: fit(dataset: torch.utils.data.DataLoader) -> None .. py:method:: format_online_targets(targets: Tuple[torch.Tensor, Ellipsis]) -> torch.Tensor