8000 GitHub - jotaporras/loss-shaping: Repository for the paper Loss Shaping Constraints for Long-Term Time Series Forecasting https://arxiv.org/abs/2402.09373
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Repository for the paper Loss Shaping Constraints for Long-Term Time Series Forecasting https://arxiv.org/abs/2402.09373

License

Notifications You must be signed in to change notification settings

jotaporras/loss-shaping

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Loss Shaping Constraints for Time Series Forecasting

Official implementation of the experiments in "Loss Shaping Constraints for Long-Term Time Series Forecasting" (ICML 2024). Forked from Autoformer.

Setup

Environment setup:

# Create and activate conda environment
conda env create -f environment.yml
conda activate loss-shaping

Set up W&B (optional):

wandb login

The datasets can be downloaded from this link. Alternatively, run make get_dataset. The expected structure is {root_path}/{data_path}.csv.

Usage

The following examples show how to run ERM and constrained trainings using the Autoformer model on the ECL dataset.

To avoid using W&B, you can add the flag WANDB_DISABLED=true to the python command, or just use the CLI prompt when running the script.

ERM Training

python run.py \
    --wandb_project WandbProject \
    --wandb_run example-run \
    --model Autoformer \
    --model_id electricity \
    --data custom \
    --root_path ./dataset/electricity/ \
    --data_path electricity.csv \
    --features M \
    --seq_len 96 \
    --label_len 48 \
    --pred_len 192 \
    --e_layers 3 \
    --d_layers 1 \
    --factor 3 \
    --enc_in 321 \
    --dec_in 321 \
    --c_out 321 \
    --n_heads 16 \
    --d_model 128 \
    --d_ff 256 \
    --dropout 0.2 \
    --train_epochs 25 \
    --patience 10 \
    --batch_size 32 \
    --learning_rate 0.0001 \
    --is_training 1 \
    --constraint_type erm

Constrained Training

python run.py \
    --wandb_project WandbProject \
    --wandb_run example-run \
    --model Autoformer \
    --model_id electricity \
    --data custom \
    --root_path ./dataset/electricity/ \
    --data_path electricity.csv \
    --features M \
    --seq_len 96 \
    --label_len 48 \
    --pred_len 192 \
    --e_layers 3 \
    --d_layers 1 \
    --factor 3 \
    --enc_in 321 \
    --dec_in 321 \
    --c_out 321 \
    --n_heads 16 \
    --d_model 128 \
    --d_ff 256 \
    --dropout 0.2 \
    --train_epochs 25 \
    --patience 10 \
    --batch_size 32 \
    --learning_rate 0.0001 \
    --is_training 1 \
    --constraint_type constant \
    --constraint_level 0.167 \
    --dual_lr 0.01 \
    --dual_init 1.0

Key arguments (added by us):

  • constraint_type: Type of constraint to use during training. ERM is unconstrained.
    • Supported constraint types: erm, constant, static_linear, dynamic_linear, resilience, monotonic, static_exponential
  • constraint_level: Upper bound on loss at each timestep (for constant constraints)
  • dual_lr: Learning rate for dual variables
  • dual_init: Initial value for dual variables.

Alternatively, the sweeps/ directory contains YAML files for running W&B Sweeps, which were used for the paper experiments. To run:

wandb sweep sweeps/{sweep_name}.yaml
wandb agent {sweep_id} #get the sweep_id from the previous command's output.

For more details on other arguments see the argparse help, or refer to the original Autoformer repository.

Supported Models

Transformer-Based:

  • Autoformer
  • Informer
  • Reformer
  • Pyraformer
  • iTransformer
  • Nonstationary Transformer
  • Vanilla Transformer

Other:

  • FiLM (Feature-wise Linear Modulation)

Supported Datasets

  • Electricity Consumption Load (ECL)
  • ETT (Electricity Transformer Temperature)
  • Weather
  • Exchange Rate
  • Traffic
  • Influenza-Like Illness (ILI)

Acknowledgements

This implementation builds upon the Autoformer repository. We thank the original authors for their open-source contribution.

About

Repository for the paper Loss Shaping Constraints for Long-Term Time Series Forecasting https://arxiv.org/abs/2402.09373

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 70.1%
  • Shell 29.7%
  • Makefile 0.2%
0