1. MLP
Multi-Layer PerceptronMLP
Module
Multi-Layer Perceptron for time series forecasting.
A feedforward neural network with configurable depth and width. The networkconsists of an input layer, multiple hidden layers with activation functions
and dropout, and an output layer. All hidden layers have the same dimensionality. Parameters:
Returns:
2. Temporal Convolutions
For long time in deep learning, sequence modelling was synonymous with recurrent networks, yet several papers have shown that simple convolutional architectures can outperform canonical recurrent networks like LSTMs by demonstrating longer effective memory. References -van den Oord, A., Dieleman, S., Zen, H., Simonyan, K., Vinyals, O., Graves, A., Kalchbrenner, N., Senior, A. W., & Kavukcuoglu, K. (2016). Wavenet: A generative model for raw audio. Computing Research Repository, abs/1609.03499. URL: http://arxiv.org/abs/1609.03499. arXiv:1609.03499. -Shaojie Bai, Zico Kolter, Vladlen Koltun. (2018). An Empirical Evaluation of Generic Convolutional and Recurrent Networks for Sequence Modeling. Computing Research Repository, abs/1803.01271. URL: https://arxiv.org/abs/1803.01271.Chomp1d
Module
Temporal trimming layer for 1D sequences.
Removes the rightmost horizon timesteps from a 3D tensor. This is commonlyused to trim padding added by convolution operations, ensuring the output
sequence has the desired length. The operation trims the temporal dimension: [N, C, T] -> [N, C, T-horizon] Parameters:
Returns:
CausalConv1d
CausalConv1d
Module
Causal Convolution 1d
Receives x input of dim [N,C_in,T], and computes a causal convolution
in the time dimension. Skipping the H steps of the forecast horizon, through
its dilation.
Consider a batch of one element, the dilated convolution operation on the
time step is defined:
where is the dilation factor, is the kernel size, is the index of
the considered past observation. The dilation effectively applies a filter with skip
connections. If one recovers a normal convolution.
Parameters:
Returns:
TemporalConvolutionEncoder
3. Transformers
References- Haoyi Zhou, Shanghang Zhang, Jieqi Peng, Shuai Zhang, Jianxin Li, Hui Xiong, Wancai Zhang. “Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecasting”
- Haixu Wu, Jiehui Xu, Jianmin Wang, Mingsheng Long.
TransEncoder
Module
Transformer Encoder.
A stack of transformer encoder layers that processes input sequences throughmultiple self-attention and feed-forward layers. Optionally includes convolutional
layers between attention layers for distillation and a final normalization layer. Parameters:
Returns:
TransEncoderLayer
Module
Transformer Encoder Layer.
A single layer of the transformer encoder that applies self-attention followed bya position-wise feed-forward network with residual connections and layer normalization.
Dropout is applied after the self-attention output and twice in the feed-forward network
(after each convolution) before the residual connections for regularization. Parameters:
Returns:
TransDecoder
Module
Transformer decoder module for sequence-to-sequence forecasting.
Stacks multiple TransDecoderLayer modules to process decoder inputs withself-attention and cross-attention mechanisms. Optionally applies layer
normalization and a final projection layer to produce output predictions. Parameters:
Returns:
TransDecoderLayer
Module
Transformer Decoder Layer.
A single layer of the transformer decoder that applies masked self-attention,cross-attention with encoder outputs, and a position-wise feed-forward network
with residual connections and layer normalization. Dropout is applied after each
sub-layer (self-attention, cross-attention, and twice in the feed-forward network)
before the residual connection for regularization. Parameters:
Returns:
AttentionLayer
Module
Multi-head attention layer wrapper.
This layer wraps an attention mechanism and handles the linear projectionsfor queries, keys, and values in multi-head attention. It projects inputs
to multiple heads, applies the inner attention mechanism, and projects back
to the original hidden dimension. Parameters:
Returns:
FullAttention
Module
Full attention mechanism with scaled dot-product attention.
Implements standard multi-head attention using scaled dot-product attention.Supports both efficient computation via PyTorch’s scaled_dot_product_attention
and explicit attention computation when attention weights are needed. Optional
causal masking prevents attention to future positions in autoregressive models. Parameters:
Returns:
TriangularCausalMask
from attending to future positions in the sequence. This ensures causality
in autoregressive models where predictions at time t should only depend on
positions before t. The mask is created using torch.triu with diagonal=1, resulting in a mask
where positions (i, j) are True when j > i, effectively masking out future
positions during attention computation. Parameters:
Attributes:
DataEmbedding_inverted
Module
Inverted data embedding module for variate-as-token transformer architectures.
Transforms time series data by treating each variate (channel) as a token ratherthan each time step. The input is permuted from [Batch, Time, Variate] to
[Batch, Variate, Time], then a linear layer projects the time dimension to the
hidden dimension. Optionally concatenates temporal covariates along the variate
dimension. Parameters:
Returns:
DataEmbedding
Module
Data embedding module combining value, positional, and temporal embeddings.
Transforms time series data into high-dimensional embeddings by combining:
- Value embeddings: Convolutional encoding of the time series values
- Positional embeddings: Sinusoidal encodings for relative position within window
- Temporal embeddings: Linear projection of absolute calendar features (optional)
Returns:
TemporalEmbedding
Module
Temporal embedding module for encoding calendar-based time features.
Creates learnable or fixed embeddings for temporal features including month,day, weekday, hour, and optionally minute. These embeddings are summed to
produce a combined temporal representation. Parameters:
Returns:
FixedEmbedding
Module
Fixed sinusoidal embedding for categorical temporal features.
Creates non-trainable embeddings using sine and cosine functions at differentfrequencies. Unlike PositionalEmbedding which encodes continuous positions,
FixedEmbedding is designed for discrete categorical inputs (e.g., hour of day,
day of month, month of year). The embeddings are precomputed and frozen,
making them non-learnable parameters. Parameters:
Returns:
TimeFeatureEmbedding
Module
Linear embedding for temporal/calendar features.
Transforms time-based features (e.g., hour, day, month) into embeddings usinga single linear projection without bias. This embedding is typically used to
incorporate calendar information into transformer models, providing absolute
temporal context that complements positional encodings. Parameters:
Returns:
PositionalEmbedding
Module
Sinusoidal positional embedding for transformer models.
Generates fixed sinusoidal positional encodings using sine and cosine functionsat different frequencies. These encodings provide position information to
transformer models, allowing them to understand the relative or absolute position
of tokens in a sequence. The encodings are precomputed and stored as a buffer,
making them non-trainable. Parameters:
Returns:
SeriesDecomp
Module
Series decomposition block for trend-residual decomposition.
Decomposes time series into trend and residual components using moving average
filtering. The trend is extracted via a moving average filter, and the residual
is computed as the difference between the input and the trend.
Parameters:
Returns:
MovingAvg
Module
Moving average block to highlight the trend of time series.
Applies a moving average filter using 1D average pooling to smooth time seriesdata and extract trend components. The input is padded on both ends by repeating
the first and last values to maintain the original sequence length. Parameters:
Returns:
RevIN
Module
Reversible Instance Normalization for time series forecasting.
Normalizes time series data by removing the mean (or last value) and scaling bystandard deviation. The normalization can be reversed after model predictions to
restore the original scale. Optionally includes learnable affine parameters for
additional transformation flexibility. Parameters:
Returns:
RevINMultivariate
Module
Reversible Instance Normalization for multivariate time series models.
Normalizes multivariate time series data using batch statistics computed acrossthe time dimension. The normalization can be reversed after model predictions to
restore the original scale. Optionally includes learnable affine parameters for
additional transformation flexibility. Parameters:
Returns:

