timesead.models.generative
Submodules
- timesead.models.generative.beatgan
- timesead.models.generative.donut
- timesead.models.generative.gru_gmm_vae
- timesead.models.generative.lstm_vae
- timesead.models.generative.lstm_vae_gan
- timesead.models.generative.madgan
- timesead.models.generative.omni_anomaly
- timesead.models.generative.sis_vae
- timesead.models.generative.tadgan
Classes
Base class for all neural network modules. |
|
Base class for all neural network modules. |
|
Implements BeatGANs time-series distortion. This should be applied after windowing. |
|
Base class for all neural network modules. |
|
We decided not to include the reconstruction step from the paper here, since we don't have missing data. |
|
Base class for all neural network modules. |
|
Use sampled log likelihood of data |
|
Base class for all neural network modules. |
|
Base class for all neural network modules. |
|
Base class for all neural network modules. |
|
Use sampled log likelihood of data + some thresholding mechanism |
|
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. |
|
We decided not to include the reconstruction step from the paper here, since we don't have missing data. |
|
Base class for all neural network modules. |
|
We decided not to include the reconstruction step from the paper here, since we don't have missing data. |
|
Base class for all neural network modules. |
|
Package Contents
- class timesead.models.generative.BeatGANModel(input_dim: int, conv_filters: int = 32, latent_dim: int = 50, last_kernel_size: int = 10)
Bases:
timesead.models.BaseModel,timesead.models.common.GANBase 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.
- 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[torch.nn.Parameter], Ellipsis]
- Return type:
Tuple[Iterator[torch.nn.Parameter], Ellipsis]
- class timesead.models.generative.BeatGANGeneratorLoss(adversarial_weight: float = 1.0)
Bases:
timesead.optim.loss.LossBase 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:
adversarial_weight (float)
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- adversarial_weight = 1.0
- mse_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.BeatGANDiscriminatorLoss
Bases:
timesead.models.common.GANDiscriminatorLoss- 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.BeatGANReconstructionAnomalyDetector(model: BeatGANModel)
Bases:
timesead.models.common.MSEReconstructionAnomalyDetector- Parameters:
model (BeatGANModel)
- 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:
- class timesead.models.generative.WrapAugmentTransform(parent: timesead.data.transforms.Transform, distort_fraction: float = 0.05, n_augmentations: int = 1)
Bases:
timesead.data.transforms.TransformImplements BeatGANs time-series distortion. This should be applied after windowing.
- Parameters:
parent (timesead.data.transforms.Transform) – This transform’s parent.
distort_fraction (float) – Fraction of time points that should be distorted. Note that 2 distortions are applied, so in the end distor_fraction*2 data points will be distorted
n_data_augmentations – For each original time-series in parent, this will produce n_data_augmentations additional augmented time series
n_augmentations (int)
- distort_fraction = 0.05
- n_augmentations = 1
- aug_ts(x: torch.Tensor) torch.Tensor
- Parameters:
x (torch.Tensor)
- Return type:
- class timesead.models.generative.Donut(input_dim: int, hidden_dims: List[int] = [100, 100], latent_dim: int = 20, mask_prob: float = 0.01)
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:
Xu2018
- Parameters:
- latent_dim = 20
- mask_prob = 0.01
- vae
- forward(inputs: Tuple[torch.Tensor]) Tuple[torch.Tensor, Ellipsis]
- Parameters:
inputs (Tuple[torch.Tensor])
- Return type:
Tuple[torch.Tensor, Ellipsis]
- class timesead.models.generative.MaskedVAELoss(size_average=None, reduce=None, reduction: str = 'mean')
Bases:
timesead.models.common.VAELoss- Parameters:
reduction (str)
- 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.DonutAnomalyDetector(model: Donut, num_mc_samples: int = 1024)
Bases:
timesead.models.common.AnomalyDetectorWe decided not to include the reconstruction step from the paper here, since we don’t have missing data.
- model
- num_mc_samples = 1024
- compute_online_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- compute_offline_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- fit(dataset: torch.utils.data.DataLoader) None
- Parameters:
dataset (torch.utils.data.DataLoader)
- Return type:
None
- format_online_targets(targets: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
targets (Tuple[torch.Tensor, Ellipsis])
- Return type:
- class timesead.models.generative.GRUGMMVAE(input_dim: int, gru_hidden_dims: List[int] = [60], latent_dim: int = 8, gmm_components: int = 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:
Guo2018 (more or less)
- latent_dim = 8
- gmm_components = 2
- encoder_rnn
- encoder_component
- vae
- prior_means
- prior_std
- softplus
- get_prior(batch_size: int, seq_len: int) Tuple[torch.Tensor | None, torch.Tensor | None]
- Parameters:
- Return type:
Tuple[Optional[torch.Tensor], Optional[torch.Tensor]]
- forward(inputs: Tuple[torch.Tensor]) Tuple[torch.Tensor, Ellipsis]
- Parameters:
inputs (Tuple[torch.Tensor])
- Return type:
Tuple[torch.Tensor, Ellipsis]
- class timesead.models.generative.GMMVAELoss
Bases:
timesead.models.common.VAELoss- 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.GMMVAEAnomalyDetector(model: GRUGMMVAE, num_mc_samples: int = 1)
Bases:
timesead.models.common.AnomalyDetectorUse sampled log likelihood of data
- model
- num_mc_samples = 1
- compute_online_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- compute_offline_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- fit(dataset: torch.utils.data.DataLoader) None
- Parameters:
dataset (torch.utils.data.DataLoader)
- Return type:
None
- format_online_targets(targets: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
targets (Tuple[torch.Tensor, Ellipsis])
- Return type:
- class timesead.models.generative.LSTMVAE(input_dim: int, lstm_hidden_dims: List[int] = [60], latent_dim: int = 20)
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:
Base LSTMVAE
- latent_dim = 20
- vae
- get_prior(batch_size: int, seq_len: int) Tuple[torch.Tensor | None, torch.Tensor | None]
- Parameters:
- Return type:
Tuple[Optional[torch.Tensor], Optional[torch.Tensor]]
- forward(inputs: Tuple[torch.Tensor]) Tuple[torch.Tensor, Ellipsis]
- Parameters:
inputs (Tuple[torch.Tensor])
- Return type:
Tuple[torch.Tensor, Ellipsis]
- class timesead.models.generative.LSTMVAEPark(input_dim: int, lstm_hidden_dims: List[int] = [60], latent_dim: int = 20, noise_std: float = 0.1)
Bases:
LSTMVAEBase 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:
Park2018
- noise_std = 0.1
- prior_means
- get_prior(batch_size: int, seq_len: int) Tuple[torch.Tensor | None, torch.Tensor | None]
- Parameters:
- Return type:
Tuple[Optional[torch.Tensor], Optional[torch.Tensor]]
- forward(inputs: Tuple[torch.Tensor]) Tuple[torch.Tensor, Ellipsis]
- Parameters:
inputs (Tuple[torch.Tensor])
- Return type:
Tuple[torch.Tensor, Ellipsis]
- class timesead.models.generative.LSTMVAESoelch(input_dim: int, lstm_hidden_dims: List[int] = [60], latent_dim: int = 20, prior_hidden_dim: int = 40)
Bases:
LSTMVAEBase 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:
Sölch2016
- prior_rnn
- prior_linear
- get_prior(batch_size: int, seq_len: int) Tuple[torch.Tensor | None, torch.Tensor | None]
- Parameters:
- Return type:
Tuple[Optional[torch.Tensor], Optional[torch.Tensor]]
- class timesead.models.generative.VAEAnomalyDetectorPark(model: LSTMVAEPark, num_mc_samples: int = 1)
Bases:
timesead.models.common.AnomalyDetectorUse sampled log likelihood of data + some thresholding mechanism
- Parameters:
model (LSTMVAEPark)
num_mc_samples (int)
- model
- num_mc_samples = 1
- svr
- compute_threshold(z: torch.Tensor)
- Parameters:
z (torch.Tensor)
- compute_online_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- compute_offline_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- fit(dataset: torch.utils.data.DataLoader) None
- Parameters:
dataset (torch.utils.data.DataLoader)
- Return type:
None
- format_online_targets(targets: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
targets (Tuple[torch.Tensor, Ellipsis])
- Return type:
- class timesead.models.generative.VAEAnomalyDetectorSoelch(model: LSTMVAESoelch)
Bases:
timesead.models.common.AnomalyDetector- Parameters:
model (LSTMVAESoelch)
- model
- loss
- compute_online_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- compute_offline_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- fit(dataset: torch.utils.data.DataLoader) None
- Parameters:
dataset (torch.utils.data.DataLoader)
- Return type:
None
- format_online_targets(targets: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
targets (Tuple[torch.Tensor, Ellipsis])
- Return type:
- class timesead.models.generative.RNNVAEGaussianEncoder(input_dim: int, rnn_type: str = 'lstm', rnn_hidden_dims: List[int] = [60], latent_dim: int = 10, bidirectional: bool = False, mode: str = 's2s', logvar_out: bool = True)
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.
- logvar = True
- rnn
- linear
- softplus
- forward(x: torch.Tensor) Tuple[torch.Tensor, torch.Tensor]
- Parameters:
x (torch.Tensor)
- Return type:
Tuple[torch.Tensor, torch.Tensor]
- class timesead.models.generative.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.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.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:
- class timesead.models.generative.MADGAN(input_dim: int, latent_dim: int = 15, generator_hidden_dims: List[int] = [100, 100, 100], discriminator_hidden_dims: List[int] = [100])
Bases:
timesead.models.common.GAN,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 = 15
- grouped_parameters() Tuple[Iterator[torch.nn.Parameter], Ellipsis]
- Return type:
Tuple[Iterator[torch.nn.Parameter], Ellipsis]
- class timesead.models.generative.MADGANTrainer(*args, disc_iterations: int = 1, gen_iterations: int = 3, **kwargs)
Bases:
timesead.optim.trainer.Trainer- disc_iterations = 1
- gen_iterations = 3
- 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]
- Parameters:
network (MADGAN)
val_metrics (Dict[str, Callable])
b_inputs (Tuple[torch.Tensor, Ellipsis])
b_targets (Tuple[torch.Tensor, Ellipsis])
- Return type:
- 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]
- Parameters:
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])
- Return type:
List[float]
- class timesead.models.generative.MADGANAnomalyDetector(model: MADGAN, max_iter: int = 1000, lambder: float = 0.5, rec_error_tolerance: float = 0.1)
Bases:
timesead.models.common.AnomalyDetector- model
- max_iter = 1000
- lambder = 0.5
- rec_error_tolerance = 0.1
- rbf_kernel
- compute_online_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- compute_offline_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- fit(dataset: torch.utils.data.DataLoader) None
- Parameters:
dataset (torch.utils.data.DataLoader)
- Return type:
None
- format_online_targets(targets: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
targets (Tuple[torch.Tensor, Ellipsis])
- Return type:
- class timesead.models.generative.OmniAnomaly(input_dim: int, latent_dim: int = 3, rnn_hidden_dims: Sequence[int] = (500,), dense_hidden_dims: Sequence[int] = (500, 500), nf_layers: int = 20)
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 = 3
- prior
- enc_rnn
- encoder_vae
- latent_nf
- decoder_rnn
- decoder_vae
- forward(inputs: Tuple[torch.Tensor], num_samples: int = 1) Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.nn.Module, torch.Tensor, torch.Tensor]
- Parameters:
inputs (Tuple[torch.Tensor])
num_samples (int)
- Return type:
Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.nn.Module, torch.Tensor, torch.Tensor]
- class timesead.models.generative.OmniAnomalyLoss
Bases:
timesead.optim.loss.LossBase 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.
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(predictions: Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.nn.Module, torch.Tensor, torch.Tensor], targets: Tuple[torch.Tensor, Ellipsis], *args, **kwargs) torch.Tensor
- Parameters:
predictions (Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.nn.Module, torch.Tensor, torch.Tensor])
targets (Tuple[torch.Tensor, Ellipsis])
- Return type:
- class timesead.models.generative.OmniAnomalyDetector(model: OmniAnomaly, num_mc_samples: int = 1024)
Bases:
timesead.models.common.AnomalyDetectorWe decided not to include the reconstruction step from the paper here, since we don’t have missing data.
- Parameters:
model (OmniAnomaly)
num_mc_samples (int)
- model
- num_mc_samples = 1024
- compute_online_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- compute_offline_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- fit(dataset: torch.utils.data.DataLoader) None
- Parameters:
dataset (torch.utils.data.DataLoader)
- Return type:
None
- format_online_targets(targets: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
targets (Tuple[torch.Tensor, Ellipsis])
- Return type:
- class timesead.models.generative.SISVAE(input_dim: int, rnn_hidden_dim: int = 200, latent_dim: int = 40, x_hidden_dims: List[int] = [100], z_hidden_dims: List[int] = [100], enc_hidden_dims: List[int] = [100], dec_hidden_dims: List[int] = [100], prior_hidden_dims: List[int] = [100])
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:
Li2021, ist aber im Prinzip nur Chung2015 mit einem extra loss term
- Parameters:
- latent_dim = 40
- x_embed
- z_embed
- encoder
- decoder
- prior_decoder
- rnn_cell
- softplus
- forward(inputs: Tuple[torch.Tensor]) Tuple[torch.Tensor, Ellipsis]
- Parameters:
inputs (Tuple[torch.Tensor])
- Return type:
Tuple[torch.Tensor, Ellipsis]
- class timesead.models.generative.SISVAELossWithGeneratedPrior(smooth_weight: float = 0.5)
Bases:
timesead.models.common.VAELoss- Parameters:
smooth_weight (float)
- smooth_weight = 0.5
- 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.SISVAEAnomalyDetector(model: SISVAE, num_mc_samples: int = 128)
Bases:
timesead.models.common.AnomalyDetectorWe decided not to include the reconstruction step from the paper here, since we don’t have missing data.
- model
- num_mc_samples = 128
- compute_online_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- compute_offline_anomaly_score(inputs: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
inputs (Tuple[torch.Tensor, Ellipsis])
- Return type:
- fit(dataset: torch.utils.data.DataLoader) None
- Parameters:
dataset (torch.utils.data.DataLoader)
- Return type:
None
- format_online_targets(targets: Tuple[torch.Tensor, Ellipsis]) torch.Tensor
- Parameters:
targets (Tuple[torch.Tensor, Ellipsis])
- Return type:
- class timesead.models.generative.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.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.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.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: