Timeseries Learning Library for PyTorch.
Project description
pytorch_timeseries
An all in one deep learning library that boost your timeseries research.
installation
pip install pytorch-timeseries
documentation
See Documentation.
Quick Start
from torch_timeseries.dataset import ETTh1
from torch_timeseries.dataloader import StandardScaler, SlidingWindow, SlidingWindowTS
from torch_timeseries.model import DLinear
from torch.nn import MSELoss, L1Loss
from torch.optim import Adam
dataset = ETTh1('./data')
scaler = StandardScaler()
dataloader = SlidingWindowTS(dataset,
window=96,
horizon=1,
steps=336,
batch_size=32,
train_ratio=0.7,
val_ratio=0.2,
scaler=scaler,
)
model = DLinear(dataloader.window, dataloader.steps, dataset.num_features, individual= True)
optimizer = Adam(model.parameters())
loss_function = MSELoss()
# train
model.train()
for scaled_x, scaled_y, x, y, x_date_enc, y_date_enc in dataloader.train_loader:
optimizer.zero_grad()
scaled_x = scaled_x.float()
scaled_y = scaled_y.float()
scaled_pred_y = model(scaled_x)
loss = loss_function(scaled_pred_y, scaled_y)
loss.backward()
optimizer.step()
print(loss)
# val
model.eval()
for scaled_x, scaled_y, x, y, x_date_enc, y_date_enc in dataloader.val_loader:
scaled_x = scaled_x.float()
scaled_y = scaled_y.float()
scaled_pred_y = model(scaled_x)
loss = loss_function(scaled_pred_y, scaled_y)
# test
model.eval()
for scaled_x, scaled_y, x, y, x_date_enc, y_date_enc in dataloader.test_loader:
scaled_x = scaled_x.float()
scaled_y = scaled_y.float()
scaled_pred_y = model(scaled_x)
loss = loss_function(scaled_pred_y, scaled_y)
dev install
install requirements
Note:This library assumes that you've installed Pytorch according to it's official website, the basic dependencies of torch > > related libraries may not be listed in the requirements files: https://pytorch.org/get-started/locally/
The recommended python version is 3.8.1+. Please first install torch according to your environment.
pip3 install torch torchvision torchaudio
For running Graph Nerual Network based models, pytorch_geometric is also needed.
pip install torch_geometric
# Optional dependencies
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.0.0+cu118.html
check your torch & cuda version before you execute the command above
python -c "import torch; print(torch.__version__)" python -c "import torch; print(torch.version.cuda)"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file torch_timeseries-0.0.1.tar.gz
.
File metadata
- Download URL: torch_timeseries-0.0.1.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0409c19a7d56ba17752b15112ef63e741a9fdae9fdcf17e7be02db27eb496b16 |
|
MD5 | 61b9e6c59028901b93d047e95cf96431 |
|
BLAKE2b-256 | b0a2029bc3aa47ade87f571ced4ee05014a179e86759e690b4746fa061d7d582 |
File details
Details for the file torch_timeseries-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: torch_timeseries-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52b56022e55c18c2a38b2fcb85153a89f7b8f3a8aea94e44254a958351e23558 |
|
MD5 | b5af3d974d8d2c9d4a95ab56d8966d58 |
|
BLAKE2b-256 | 02d019bbf85ca95c3182197d02722c0c23bfb06a606c1a141dcfa541f358964e |