timesead.models.generative.gru_gmm_vae
Classes
Base class for all neural network modules. |
|
Base class for all neural network modules. |
|
Use sampled log likelihood of data |
Module Contents
- class timesead.models.generative.gru_gmm_vae.RNNVAECategoricalEncoder(input_dim: int, rnn_type: str = 'lstm', rnn_hidden_dims: List[int] = [60], categories: int = 10, bidirectional: bool = False, mode: str = 's2s')
Bases:
torch.nn.ModuleBase 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:
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- rnn
- linear
- forward(x: torch.Tensor) torch.Tensor
- Parameters:
x (torch.Tensor)
- Return type:
- class timesead.models.generative.gru_gmm_vae.GRUGMMVAE(input_dim: int, gru_hidden_dims: List[int] = [60], latent_dim: int = 8, gmm_components: int = 2)
Bases:
timesead.models.BaseModelBase 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:
Guo2018 (more or less)
- latent_dim = 8
- gmm_components = 2
- encoder_rnn
- encoder_component
- vae
- prior_means
- prior_std
- softplus
- get_prior(batch_size: int, seq_len: int) Tuple[torch.Tensor | None, torch.Tensor | None]
- Parameters:
- Return type:
Tuple[Optional[torch.Tensor], Optional[torch.Tensor]]
- forward(inputs: Tuple[torch.Tensor]) Tuple[torch.Tensor, Ellipsis]
- Parameters:
inputs (Tuple[torch.Tensor])
- Return type:
Tuple[torch.Tensor, Ellipsis]
- class timesead.models.generative.gru_gmm_vae.GMMVAELoss
Bases:
timesead.models.common.VAELoss- forward(predictions: Tuple[torch.Tensor, Ellipsis], targets: Tuple[torch.Tensor, Ellipsis], *args, **kwargs) torch.Tensor
- Parameters:
predictions (Tuple[torch.Tensor, Ellipsis])
targets (Tuple[torch.Tensor, Ellipsis])
- Return type:
- class timesead.models.generative.gru_gmm_vae.GMMVAEAnomalyDetector(model: GRUGMMVAE, num_mc_samples: int = 1)
Bases:
timesead.models.common.AnomalyDetectorUse sampled log likelihood of data
- model
- num_mc_samples = 1
- compute_online_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- compute_offline_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- 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: