timesead.models.generative.omni_anomaly ======================================= .. py:module:: timesead.models.generative.omni_anomaly Classes ------- .. autoapisummary:: timesead.models.generative.omni_anomaly.KalmanFilter timesead.models.generative.omni_anomaly.OmniAnomaly timesead.models.generative.omni_anomaly.OmniAnomalyLoss timesead.models.generative.omni_anomaly.OmniAnomalyDetector Module Contents --------------- .. py:class:: KalmanFilter(state_dim: int, observation_dim: int) Bases: :py:obj:`torch.nn.Module` 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 Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:attribute:: state_dim .. py:attribute:: observation_dim .. py:attribute:: F .. py:attribute:: state_cov .. py:attribute:: H .. py:attribute:: obs_cov .. py:method:: forward(observations: torch.Tensor) -> torch.Tensor .. py:class:: OmniAnomaly(input_dim: int, latent_dim: int = 3, rnn_hidden_dims: Sequence[int] = (500, ), dense_hidden_dims: Sequence[int] = (500, 500), nf_layers: int = 20) 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 Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:attribute:: latent_dim :value: 3 .. py:attribute:: prior .. py:attribute:: enc_rnn .. py:attribute:: encoder_vae .. py:attribute:: latent_nf .. py:attribute:: decoder_rnn .. py:attribute:: decoder_vae .. py:method:: forward(inputs: Tuple[torch.Tensor], num_samples: int = 1) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.nn.Module, torch.Tensor, torch.Tensor] .. py:class:: OmniAnomalyLoss Bases: :py:obj:`timesead.optim.loss.Loss` 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 Initialize internal Module state, shared by both nn.Module and ScriptModule. .. py:method:: forward(predictions: Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.nn.Module, torch.Tensor, torch.Tensor], targets: Tuple[torch.Tensor, Ellipsis], *args, **kwargs) -> torch.Tensor .. py:class:: OmniAnomalyDetector(model: OmniAnomaly, 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