timesead.models.generative.lstm_vae_gan
Classes
Base class for all neural network modules. |
|
Base class for all neural network modules. |
|
Base class for all neural network modules. |
|
Module Contents
- class timesead.models.generative.lstm_vae_gan.LSTMVAEGANDecoder(input_dim: int, lstm_hidden_dims: List[int] = [60], latent_dim: int = 10)
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_mean
- forward(x: torch.Tensor) Tuple[torch.Tensor, torch.Tensor]
- Parameters:
x (torch.Tensor)
- Return type:
Tuple[torch.Tensor, torch.Tensor]
- class timesead.models.generative.lstm_vae_gan.LSTMVAEGANDiscriminator(input_dim: int, lstm_hidden_dims: List[int] = [60])
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
- forward(x: torch.Tensor) Tuple[torch.Tensor, torch.Tensor]
- Parameters:
x (torch.Tensor)
- Return type:
Tuple[torch.Tensor, torch.Tensor]
- class timesead.models.generative.lstm_vae_gan.LSTMVAEGAN(input_dim: int, lstm_hidden_dims: List[int] = [60], latent_dim: int = 10)
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:
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- latent_dim = 10
- encoder
- decoder
- discriminator
- classifier
- vae
- forward(inputs: Tuple[torch.Tensor, Ellipsis]) Tuple[torch.Tensor, Ellipsis]
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
Tuple[torch.Tensor, Ellipsis]
- grouped_parameters() Tuple[Iterator[inspect.Parameter], Ellipsis]
- Return type:
Tuple[Iterator[inspect.Parameter], Ellipsis]
- class timesead.models.generative.lstm_vae_gan.LSTMVAEGANTrainer(*args, **kwargs)
Bases:
timesead.optim.trainer.Trainer- 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]
- Parameters:
network (LSTMVAEGAN)
val_metrics (Dict[str, Callable])
b_inputs (Tuple[torch.Tensor, Ellipsis])
b_targets (Tuple[torch.Tensor, Ellipsis])
- Return type:
- 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]
- Parameters:
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])
- Return type:
List[float]
- class timesead.models.generative.lstm_vae_gan.LSTMVAEGANAnomalyDetector(model: LSTMVAEGAN, alpha: float = 0.5)
Bases:
timesead.models.common.AnomalyDetector- Parameters:
model (LSTMVAEGAN)
alpha (float)
- model
- alpha = 0.5
- fit(dataset: torch.utils.data.DataLoader) None
- Parameters:
dataset (torch.utils.data.DataLoader)
- Return type:
None
- compute_online_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- abstract compute_offline_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- format_online_targets(targets: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
targets (Tuple[torch.Tensor, Ellipsis])
- Return type: