timesead.models.generative.tadgan
Classes
Base class for all neural network modules. |
|
Base class for all neural network modules. |
|
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.tadgan.TADGANEncoder(input_size: int, window_size: int, lstm_hidden_size: int = 100, latent_size: int = 20)
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.
- lstm
- linear
- forward(x: torch.Tensor) torch.Tensor
- Parameters:
x (torch.Tensor)
- Return type:
- class timesead.models.generative.tadgan.TADGANGenerator(window_size: int, output_size: int, latent_size: int = 20, lstm_hidden_size: int = 64, dropout: float = 0.2)
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.
- linear1
- lstm1
- upsample
- lstm2
- linear2
- final_activation
- forward(x: torch.Tensor) torch.Tensor
- Parameters:
x (torch.Tensor)
- Return type:
- class timesead.models.generative.tadgan.TADGANDiscriminatorX(input_size: int, window_size: int, conv_filters: int = 64, conv_kernel_size: int = 5, dropout: float = 0.25)
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.
- conv1
- conv2
- conv3
- conv4
- dropout
- leakyrelu
- classification
- forward(x: torch.Tensor) torch.Tensor
- Parameters:
x (torch.Tensor)
- Return type:
- class timesead.models.generative.tadgan.TADGANDiscriminatorZ(latent_size: int, hidden_size: int = 20, dropout: float = 0.2)
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.
- linear1
- linear2
- dropout
- leakyrelu
- classification
- forward(x: torch.Tensor) torch.Tensor
- Parameters:
x (torch.Tensor)
- Return type:
- class timesead.models.generative.tadgan.TADGAN(input_size: int, window_size: int, latent_size: int = 20, enc_lstm_hidden_size: int = 100, gen_lstm_hidden_size: int = 64, disc_conv_filters: int = 64, disc_conv_kernel_size: int = 5, disc_z_hidden_size: int = 20, gen_dropout: float = 0.2, disc_dropout: float = 0.25, disc_z_dropout: float = 0.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:
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- encoder
- generator
- discriminatorx
- discriminatorz
- gan
- inverse_gan
- latent_size = 20
- grouped_parameters() Tuple[Iterator[torch.nn.Parameter], Ellipsis]
- Return type:
Tuple[Iterator[torch.nn.Parameter], Ellipsis]
- forward(inputs: Tuple[torch.Tensor, Ellipsis]) Tuple[torch.Tensor, Ellipsis]
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
Tuple[torch.Tensor, Ellipsis]
- class timesead.models.generative.tadgan.TADGANGeneratorLoss(reconstruction_coeff: float = 10)
Bases:
timesead.models.common.WassersteinGeneratorLoss- Parameters:
reconstruction_coeff (float)
- rec_coeff = 10
- rec_loss
- 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.tadgan.TADGANTrainer(*args, disc_iterations: int = 5, **kwargs)
Bases:
timesead.optim.trainer.Trainer- Parameters:
disc_iterations (int)
- disc_iterations = 5
- validate_batch(network: TADGAN, val_metrics: Dict[str, Callable], b_inputs: Tuple[torch.Tensor, Ellipsis], b_targets: Tuple[torch.Tensor, Ellipsis], *args, **kwargs) Dict[str, float]
- Parameters:
network (TADGAN)
val_metrics (Dict[str, Callable])
b_inputs (Tuple[torch.Tensor, Ellipsis])
b_targets (Tuple[torch.Tensor, Ellipsis])
- Return type:
- train_batch(network: TADGAN, 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 (TADGAN)
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.tadgan.TADGANAnomalyDetector(model: TADGAN, alpha: float = 0.5)
Bases:
timesead.models.common.AnomalyDetector- 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: