timesead.models.generative.omni_anomaly

Classes

KalmanFilter

Base class for all neural network modules.

OmniAnomaly

Base class for all neural network modules.

OmniAnomalyLoss

Base class for all neural network modules.

OmniAnomalyDetector

We decided not to include the reconstruction step from the paper here, since we don't have missing data.

Module Contents

class timesead.models.generative.omni_anomaly.KalmanFilter(state_dim: int, observation_dim: int)

Bases: 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 to(), etc.

Note

As per the example above, an __init__() call to the parent class must be made before assignment on the child.

Variables:

training (bool) – Boolean represents whether this module is in training or evaluation mode.

Parameters:
  • state_dim (int)

  • observation_dim (int)

Initialize internal Module state, shared by both nn.Module and ScriptModule.

state_dim
observation_dim
F
state_cov
H
obs_cov
forward(observations: torch.Tensor) torch.Tensor
Parameters:

observations (torch.Tensor)

Return type:

torch.Tensor

class timesead.models.generative.omni_anomaly.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: 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 to(), etc.

Note

As per the example above, an __init__() call to the parent class must be made before assignment on the child.

Variables:

training (bool) – Boolean represents whether this module is in training or evaluation mode.

Parameters:
  • input_dim (int)

  • latent_dim (int)

  • rnn_hidden_dims (Sequence[int])

  • dense_hidden_dims (Sequence[int])

  • nf_layers (int)

Initialize internal Module state, shared by both nn.Module and ScriptModule.

latent_dim = 3
prior
enc_rnn
encoder_vae
latent_nf
decoder_rnn
decoder_vae
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]
Parameters:
Return type:

Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.nn.Module, torch.Tensor, torch.Tensor]

class timesead.models.generative.omni_anomaly.OmniAnomalyLoss

Bases: 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 to(), etc.

Note

As per the example above, an __init__() call to the parent class must be made before assignment on the child.

Variables:

training (bool) – Boolean represents whether this module is in training or evaluation mode.

Initialize internal Module state, shared by both nn.Module and ScriptModule.

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
Parameters:
Return type:

torch.Tensor

class timesead.models.generative.omni_anomaly.OmniAnomalyDetector(model: OmniAnomaly, num_mc_samples: int = 1024)

Bases: timesead.models.common.AnomalyDetector

We decided not to include the reconstruction step from the paper here, since we don’t have missing data.

Parameters:
model
num_mc_samples = 1024
compute_online_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
Parameters:

inputs (Tuple[torch.Tensor, Ellipsis])

Return type:

torch.Tensor

compute_offline_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
Parameters:

inputs (Tuple[torch.Tensor, Ellipsis])

Return type:

torch.Tensor

fit(dataset: torch.utils.data.DataLoader) None
Parameters:

dataset (torch.utils.data.DataLoader)

Return type:

None

format_online_targets(targets: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
Parameters:

targets (Tuple[torch.Tensor, Ellipsis])

Return type:

torch.Tensor