https://github.com/chris-official/pytorchgaf
PyTorch accelerated GAF transform
https://github.com/chris-official/pytorchgaf
cuda gpu gramian-angular-fields image-analysis python pytorch time-series
Last synced: about 1 month ago
JSON representation
PyTorch accelerated GAF transform
- Host: GitHub
- URL: https://github.com/chris-official/pytorchgaf
- Owner: chris-official
- License: mit
- Created: 2025-04-03T13:55:43.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-05T13:07:46.000Z (about 1 year ago)
- Last Synced: 2025-04-09T16:20:01.118Z (about 1 year ago)
- Topics: cuda, gpu, gramian-angular-fields, image-analysis, python, pytorch, time-series
- Language: Python
- Homepage:
- Size: 101 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.

*Figure 1: Execution time comparison between CPU-based pyts implementation and our implementation on CPU and GPU.*
## Usage/Examples
```python
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
- [pyts GitHub](https://github.com/johannfaouzi/pyts)
- [pyts GAF](https://github.com/johannfaouzi/pyts/blob/main/pyts/image/gaf.py)