Noise Modules#
The engression mechanism relies on pre-additive stochastic noise layers. These modules are common to both the Enformer and GEnformer architectures. They inject stochastic noise into the continuous representations of the sequence to enable learning the full conditional predictive distribution.
- class genformer.noise.GaussianNoise(*args, **kwargs)[source]#
Bases:
ModuleGaussian noise injection module for the engression paradigm.
This module injects additive Gaussian noise into the continuous representations of the sequence, acting as a pre-additive stochastic noise layer. According to the paper “Deep Generative Transformers for Probabilistic Time Series and Spatiotemporal Forecasting”, injecting this stochastic noise enables the Transformer architecture to learn the full conditional predictive distribution rather than point predictions.
- Parameters:
- Mathematical Definition:
The noise \(\epsilon^{(m)}\) is sampled from a Gaussian distribution:
\[\epsilon^{(m)} \sim \mathcal{N}(\mathbf{0}, \sigma^2 \mathbf{I})\]The noise is then added to the input sequence:
\[\mathbf{X'}_{batch}^{(m)} = \mathbf{X}_{batch}^{(m)} + \epsilon^{(m)}\]
- reset_std(std=None)[source]#
Update the standard deviation of the noise.
- Parameters:
std (float | None)
- forward(x)[source]#
Injects Gaussian noise into the input tensor.
- Parameters:
x (torch.Tensor) – The input sequence representations.
- Returns:
torch.Tensor – The noise-perturbed representations.
- class genformer.noise.UniformNoise(*args, **kwargs)[source]#
Bases:
ModuleUniform noise injection module for the engression paradigm.
This module injects additive Uniform noise into the continuous representations of the sequence.
- Parameters:
- Mathematical Definition:
The noise \(\epsilon^{(m)}\) is sampled from a Uniform distribution:
\[\epsilon^{(m)} \sim \mathcal{U}(-\sigma, \sigma)\]The noise is then added to the input sequence:
\[\mathbf{X'}_{batch}^{(m)} = \mathbf{X}_{batch}^{(m)} + \epsilon^{(m)}\]
- reset_std(std=None)[source]#
Update the standard deviation parameter.
- Parameters:
std (float | None)
- forward(x)[source]#
Injects Uniform noise into the input tensor.
- Parameters:
x (torch.Tensor) – The input sequence representations.
- Returns:
torch.Tensor – The noise-perturbed representations.