timesead.models.generative.madgan ================================= .. py:module:: timesead.models.generative.madgan Classes ------- .. autoapisummary:: timesead.models.generative.madgan.MADGAN timesead.models.generative.madgan.MADGANTrainer timesead.models.generative.madgan.MADGANAnomalyDetector Module Contents --------------- .. py:class:: MADGAN(input_dim: int, latent_dim: int = 15, generator_hidden_dims: List[int] = [100, 100, 100], discriminator_hidden_dims: List[int] = [100]) Bases: :py:obj:`timesead.models.common.GAN`, :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: 15 .. py:method:: grouped_parameters() -> Tuple[Iterator[torch.nn.Parameter], Ellipsis] .. py:class:: MADGANTrainer(*args, disc_iterations: int = 1, gen_iterations: int = 3, **kwargs) Bases: :py:obj:`timesead.optim.trainer.Trainer` .. py:attribute:: disc_iterations :value: 1 .. py:attribute:: gen_iterations :value: 3 .. py:method:: validate_batch(network: MADGAN, 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: MADGAN, 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:: MADGANAnomalyDetector(model: MADGAN, max_iter: int = 1000, lambder: float = 0.5, rec_error_tolerance: float = 0.1) Bases: :py:obj:`timesead.models.common.AnomalyDetector` .. py:attribute:: model .. py:attribute:: max_iter :value: 1000 .. py:attribute:: lambder :value: 0.5 .. py:attribute:: rec_error_tolerance :value: 0.1 .. py:attribute:: rbf_kernel .. 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