Temporal Fusion Transformer is a state-of-the-art architecture for interpretable, multi-horizon time-series prediction.
To train your model using mixed or TF32 precision with Tensor Cores, perform the following steps using the default parameters of the TFT model on any of the benchmark datasets. For the specifics concerning training and inference, refer to the Advanced section.
- Clone the repository.
git clone https://github.com/NVIDIA/DeepLearningExamples
cd DeepLearningExamples/PyTorch/Forecasting/TFT
- Build the TFT PyTorch NGC container.
docker build --network=host -t tft .
- Start an interactive session in the NGC container to run training/inference.
docker run -it --rm --ipc=host --network=host --gpus all -v /path/to/your/data:/data/ tft
Note: Ensure to mount your dataset using the -v flag to make it available for training inside the NVIDIA Docker container.
- Download and preprocess datasets.
bash scripts/get_data.sh
- Start training. Choose one of the scripts provided in the
scripts/directory. Results are stored in the/resultsdirectory. These scripts are tuned for DGX1-32G. If you have a different system, use NGPU and BATCH_SIZE variables to adjust the parameters for your system.
bash scripts/run_electricity.sh
bash scripts/run_traffic.sh
- Start validation/evaluation. The metric we use for evaluation is q-risk. We can compare it per-quantile in the Pareto sense or jointly as one number indicating accuracy.
python inference.py \
--checkpoint <your_checkpoint> \
--data /data/processed/<dataset>/test.csv \
--cat_encodings /data/processed/<dataset>/cat_encodings.bin \
--tgt_scalers /data/processed/<dataset>/tgt_scalers.bin
- Start inference/predictions. Visualize and save predictions by running the following command.
python inference.py \
--checkpoint <your_checkpoint> \
--data /data/processed/<dataset>/test.csv \
--cat_encodings /data/processed/<dataset>/cat_encodings.bin \
--tgt_scalers /data/processed/<dataset>/tgt_scalers.bin \
--visualize \
--save_predictions
Now that you have your model trained and evaluated, you can choose to compare your training results with our Training accuracy results. You can also choose to benchmark your performance to Training performance benchmark. Following the steps in these sections will ensure that you achieve the same accuracy and performance results as stated in the Results section.