Skip to content

chris-official/PyTorchGAF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PyTorchGAF: PyTorch-accelerated implementation of the Gramian Angular Field (GAF)

The provided GAF implementation uses pure PyTorch. It provides the following benefits and features:

  • Supports batched data.
  • Supports multivariate time series data.
  • Handles necessary scaling before the GAF transformation.
  • Allows to use the GAF transform directly as a neural network layer.
  • Allows directly transforming the data on the target device (CPU or GPU).
  • Uses efficient vectorized Einstein Summation Notation to compute the outer products to avoid using loops.

Optimizations

Our implementation is based on the GAF transform from pyts. However, as Figure 1 shows, the GAF transform significantly benefits from GPU acceleration, achieving speedups of almost 90x for larger batch sizes.

Performance Comparison Figure 1: Execution time comparison between CPU-based pyts implementation and our implementation on CPU and GPU.

Usage/Examples

import torch

gaf = GAFTransform(method="summation")
inputs = torch.randn(32, 8, 40, device="cuda")  # (N, C, L)
output = gaf(inputs)  # (N, C, L, L)

Acknowledgements