timesead.models.generative.lstm_vae_gan ======================================= .. py:module:: timesead.models.generative.lstm_vae_gan Classes ------- .. autoapisummary:: timesead.models.generative.lstm_vae_gan.LSTMVAEGANDecoder timesead.models.generative.lstm_vae_gan.LSTMVAEGANDiscriminator timesead.models.generative.lstm_vae_gan.LSTMVAEGAN timesead.models.generative.lstm_vae_gan.LSTMVAEGANTrainer timesead.models.generative.lstm_vae_gan.LSTMVAEGANAnomalyDetector Module Contents --------------- .. py:class:: LSTMVAEGANDecoder(input_dim: int, lstm_hidden_dims: List[int] = [60], latent_dim: int = 10) 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_mean .. py:method:: forward(x: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor] .. py:class:: LSTMVAEGANDiscriminator(input_dim: int, lstm_hidden_dims: List[int] = [60]) 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:method:: forward(x: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor] .. py:class:: LSTMVAEGAN(input_dim: int, lstm_hidden_dims: List[int] = [60], latent_dim: int = 10) 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: 10 .. py:attribute:: encoder .. py:attribute:: decoder .. py:attribute:: discriminator .. py:attribute:: classifier .. py:attribute:: vae .. py:method:: forward(inputs: Tuple[torch.Tensor, Ellipsis]) -> Tuple[torch.Tensor, Ellipsis] .. py:method:: grouped_parameters() -> Tuple[Iterator[inspect.Parameter], Ellipsis] .. py:class:: LSTMVAEGANTrainer(*args, **kwargs) Bases: :py:obj:`timesead.optim.trainer.Trainer` .. py:method:: validate_batch(network: LSTMVAEGAN, val_metrics: Dict[str, Callable], b_inputs: Tuple[torch.Tensor, Ellipsis], b_targets: Tuple[torch.Tensor, Ellipsis], *args, **kwargs) -> Dict[str, float] .. py:method:: train_batch(network: LSTMVAEGAN, losses: List[timesead.optim.loss.Loss], optimizers: List[torch.optim.Optimizer], epoch: int, num_epochs: int, b_inputs: Tuple[torch.Tensor, Ellipsis], b_targets: Tuple[torch.Tensor, Ellipsis]) -> List[float] .. py:class:: LSTMVAEGANAnomalyDetector(model: LSTMVAEGAN, alpha: float = 0.5) Bases: :py:obj:`timesead.models.common.AnomalyDetector` .. py:attribute:: model .. py:attribute:: alpha :value: 0.5 .. py:method:: fit(dataset: torch.utils.data.DataLoader) -> None .. 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 :abstractmethod: .. py:method:: format_online_targets(targets: Tuple[torch.Tensor, Ellipsis]) -> torch.Tensor