timesead.models.generative.gru_gmm_vae ====================================== .. py:module:: timesead.models.generative.gru_gmm_vae Classes ------- .. autoapisummary:: timesead.models.generative.gru_gmm_vae.RNNVAECategoricalEncoder timesead.models.generative.gru_gmm_vae.GRUGMMVAE timesead.models.generative.gru_gmm_vae.GMMVAELoss timesead.models.generative.gru_gmm_vae.GMMVAEAnomalyDetector Module Contents --------------- .. py:class:: RNNVAECategoricalEncoder(input_dim: int, rnn_type: str = 'lstm', rnn_hidden_dims: List[int] = [60], categories: int = 10, bidirectional: bool = False, mode: str = 's2s') 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:: rnn .. py:attribute:: linear .. py:method:: forward(x: torch.Tensor) -> torch.Tensor .. py:class:: GRUGMMVAE(input_dim: int, gru_hidden_dims: List[int] = [60], latent_dim: int = 8, gmm_components: int = 2) 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 Guo2018 (more or less) :param input_dim: :param gru_hidden_dims: :param latent_dim: .. py:attribute:: latent_dim :value: 8 .. py:attribute:: gmm_components :value: 2 .. py:attribute:: encoder_rnn .. py:attribute:: encoder_component .. py:attribute:: vae .. py:attribute:: prior_means .. py:attribute:: prior_std .. py:attribute:: softplus .. py:method:: get_prior(batch_size: int, seq_len: int) -> Tuple[Optional[torch.Tensor], Optional[torch.Tensor]] .. py:method:: forward(inputs: Tuple[torch.Tensor]) -> Tuple[torch.Tensor, Ellipsis] .. py:class:: GMMVAELoss 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:: GMMVAEAnomalyDetector(model: GRUGMMVAE, num_mc_samples: int = 1) Bases: :py:obj:`timesead.models.common.AnomalyDetector` Use sampled log likelihood of data :param model: :param num_mc_samples: .. py:attribute:: model .. py:attribute:: num_mc_samples :value: 1 .. 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