NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
Temporal Fusion Transformer for PyTorch
Resource
NVIDIA Deep Learning Examples
NVIDIA Deep Learning Examples
Temporal Fusion Transformer for PyTorch

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.

  1. Clone the repository.
git clone https://github.com/NVIDIA/DeepLearningExamples
cd DeepLearningExamples/PyTorch/Forecasting/TFT
  1. Build the TFT PyTorch NGC container.
docker build --network=host -t tft .
  1. 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.

  1. Download and preprocess datasets.
bash scripts/get_data.sh
  1. Start training. Choose one of the scripts provided in the scripts/ directory. Results are stored in the /results directory. 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
  1. 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
  1. 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.

NVIDIA uses cookies to improve your experience on our web site. We and our third-party partners also use cookies and other tools to collect and record information you provide as well as information about your interactions with our websites for performance improvement, analytics, and to assist in marketing efforts. By clicking "Accept All", you consent to our use of cookies and other tools as described in our Cookie Policy. You can manage your cookie settings by clicking on "Manage Settings." By continuing to use this site or by clicking one of the buttons below, you agree to our Terms of Service (which contains important waivers). Please see our Privacy Policy for more information on our privacy practices.