This is the Official PyTorch Implementation for the paper:
STD2Vformer: A Free-form Spatiotemporal Forecasting Model
IEEE Transactions on Industrial Informatics (TII), 2026
Liwei Deng, Hao Wang†, Junhao Tan, Xinhe Niu, Yuxin He, Shiyao Zhang, and Zhihai He.
STD2Vformer is a novel architecture designed for free-form spatiotemporal forecasting.
Most existing models focus on fixed-horizon prediction, where the prediction starts immediately after the input with a fixed length. In contrast, free-form prediction (as illustrated in Figure 2) allows both the starting position (gap) and the length of the predicted sequence to be freely adjusted during training and inference.
Figure 2. Comparison between fixed-horizon and free-form prediction. The blue solid line represents the input, the green dashed line is the prediction, and the orange solid line indicates the interval. Left: Fixed-horizon prediction (Gap=0, fixed length). Right: Free-form prediction where both gap and prediction length can vary freely.
We recommend using Anaconda to manage your environment.
# Create a virtual environment
conda create -n STD2Vformer python=3.9
conda activate STD2Vformer
# Install dependencies
pip install -r requirements.txtWe use the standard traffic forecasting datasets: METR-LA, PEMS04, PEMS08, and PEMS-BAY.
Please organize the downloaded files in the datasets/ folder as follows:
STD2Vformer/
├── datasets/
│ ├── METR-LA/
│ ├── PEMS04/
│ ├── PEMS08/
│ └── PEMS-BAY/
├── scripts/
├── ...
STD2Vformer currently supports three experiment modes.
| Mode | Script | Description |
|---|---|---|
| Fixed-Horizon Prediction | scripts/fixed-horizon_prediction.sh |
Standard fixed-horizon forecasting |
| Free-Form No Retrain | scripts/free-form_no_retrain.sh |
Train once and evaluate multiple horizons directly |
| Free-Form Retrain | scripts/free-form_retrain.sh |
Pretrain first, then finetune for each target horizon |
Run one of the following scripts depending on the experiment setting you want.
chmod 776 ./scripts/fixed-horizon_prediction.sh
./scripts/fixed-horizon_prediction.shchmod 776 ./scripts/free-form_no_retrain.sh
./scripts/free-form_no_retrain.shchmod 776 ./scripts/free-form_retrain.sh
./scripts/free-form_retrain.shIn the paper, w/NB denotes with Non-Blind meta-information.
In this repository, that setting is controlled by:
--is_no_blind TrueThe corresponding relation is:
w/NB↔is_no_blind=Truew/o NB↔is_no_blind=False
💡 Note
The provided free-form scripts currently use
--is_no_blind Falseby default. If you want to reproduce thew/NBsetting, change it toTruein the script, or pass--is_no_blind Truemanually when runningmain.py.
| Argument | Meaning |
|---|---|
--flexible |
Enable free-form prediction |
--retrain |
Enable per-horizon retraining |
--pred_len |
Prediction horizon used during training |
--pred_len_test |
Evaluation horizons for free-form prediction |
--alpha |
Random horizon-shortening probability during training |
--is_no_blind |
Whether to use Non-Blind meta-information |
If you find this work helpful to your research, please consider citing our paper:
@ARTICLE{Deng2026,
author={Deng, Liwei and Wang, Hao and Tan, Junhao and Niu, Xinhe and He, Yuxin and Zhang, Shiyao and He, Zhihai},
journal={IEEE Transactions on Industrial Informatics},
title={STD2Vformer: A Free-Form Spatiotemporal Forecasting Model},
year={2026},
pages={1-12},
doi={10.1109/TII.2026.3655106}
}We appreciate the following github repositories for their valuable code references:
