A pip-installable PyTorch implementation of TSMixer, providing an easy-to-use and efficient solution for time-series forecasting.
A pip-installable PyTorch implementation of TSMixer, providing an easy-to-use and efficient solution for time-series forecasting.
TSMixer is an unofficial PyTorch-based implementation of the TSMixer architecture as described TSMixer Paper. It leverages mixer layers for processing time series data, offering a robust approach for both standard and extended forecasting tasks.
You can install the package using pip:
pip install pytorch-tsmixeror after cloning the repository, you can install it directly from the source code:
pip install .tsmixer.py: Contains the TSMixer class, a model using mixer layers for time series forecasting.tsmixer_ext.py: Implements the TSMixerExt class, an extended version of TSMixer that integrates additional inputs and contextual information.from torchtsmixer import TSMixer
import torch
m = TSMixer(sequence_length=10, prediction_length=5, input_channels=2, output_channels=4)
x = torch.randn(3, 10, 2)
y = m(x)from torchtsmixer import TSMixerExt
import torch
m = TSMixerExt(
sequence_length=10,
prediction_length=5,
input_channels=2,
extra_channels=3,
hidden_channels=8,
static_channels=4,
output_channels=4
)
x_hist = torch.randn(3, 10, 2, requires_grad=True)
x_extra_hist = torch.randn(3, 10, 3, requires_grad=True)
x_extra_future = torch.randn(3, 5, 3, requires_grad=True)
x_static = torch.randn(3, 4, requires_grad=True)
y = m.forward(
x_hist=x_hist,
x_extra_hist=x_extra_hist,
x_extra_future=x_extra_future,
x_static=x_static
)Here's a basic example of how to use TSMixer in a simple training loop. This example assumes a regression task with a mean squared error loss and an Adam optimizer.
…This example is quite basic and should be adapted to your specific dataset and task. For instance, you might want to add data loading with DataLoader, validation steps, and more sophisticated training logic.
Run tests using:
python -m unittestThis project is licensed under the MIT License - see the LICENSE file for details.
This implementation is based on the TSMixer model as described in TSMixer Paper.
No open issues yet, or sync has not completed.