ginjax: E(d)-Equivariant CNN for Tensor Images

Wilson Gregory, Kaze W. K. Wong, David W. Hogg, Soledad VillarJ. Open Source Softw 2025 · DOI · DBLP

Summary

ginjax is a JAX-based library that implements $E(d)$-equivariance—symmetry under translation, rotation, and reflection—for convolutional neural networks. It is specifically designed for "geometric images" where each pixel is a tensor, making it a powerful tool for modeling physical fields such as fluid velocity, magnetism, or stress.

Introduction

In the physical sciences, data often takes the form of fields discretized on a grid. Unlike standard image data where pixels represent scalar intensities (e.g., RGB values), physical fields frequently involve vectors (like wind velocity) or higher-order tensors (like stress or polarization). Modeling these fields requires neural networks that respect the underlying symmetries of Euclidean space—specifically $E(d)$-equivariance. While standard CNNs are translation-equivariant, they typically fail to account for rotations or reflections.

The Challenge of Tensor Fields

Existing equivariant network libraries often face two primary limitations:

  1. Handling Higher-Order Tensors: Many tools struggle to process pixels that are tensors of order greater than zero (scalars).
  2. Framework Availability: Most established solutions are built for PyTorch. The JAX community, which values high-performance transformations like vmap (automatic vectorization) and jit (just-in-time compilation), has lacked a dedicated tool for geometric convolutions on tensor images.

The ginjax Framework

Built on JAX and Equinox, ginjax introduces an implementation of geometric convolutions that treats every pixel as a geometric object.

Core Technical Features

  • Geometric Operations: Instead of standard scalar multiplications, ginjax utilizes tensor products and contractions. This approach ensures that the geometric properties of the input data are preserved throughout the network.
  • Symmetry Constraints: Equivariance is maintained by restricting convolution filters to be invariant under the $E(d)$ group (specifically discrete rotations and reflections).
  • The MultiImage Data Structure: To manage the complexity of tensor data, the library uses a MultiImage structure that tracks the "tensor order" and "parity" of every image, ensuring mathematical consistency across layers.
  • Drop-in Layers: The library provides equivariant versions of standard deep learning components, including activation functions, group normalization, pooling, and unpooling.

Key Features and Capabilities

ginjax is designed to be accessible for practitioners, following a "drop-in" philosophy that allows for minimal code changes when making architectures physically aware.

  • Unified Linear Layers: The library combines convolution and tensor contraction into a single operation, allowing the network to reduce tensor orders (e.g., converting a vector field into a scalar field) while maintaining equivariance.
  • JAX Integration: By leveraging JAX, ginjax inherits powerful features like automatic vectorization, facilitating the scaling of geometric operations across large datasets.
  • Pre-built Architectures: The package includes off-the-shelf equivariant models such as UNet, ResNet, and Dilated ResNet, ready for immediate use on geometric datasets.

Limitations and Future Work

Currently, ginjax focuses on discrete $E(d)$ symmetry, supporting rotations of 90 degrees. It does not yet support continuous rotations, a feature found in some "Steerable CNN" frameworks. Additionally, the library is strictly integrated with the JAX/Equinox ecosystem, requiring users of other frameworks like PyTorch to use alternative packages.

Conclusion

ginjax fills a specific niche in the scientific machine learning ecosystem as the only package implementing geometric convolutions for higher-order tensors within JAX. By providing both the underlying mathematical primitives and high-level model architectures, it enables researchers to build more physically-consistent models of complex tensor fields.

Summary updated

BibTeX
@article{gregory2025ginjax,
  author = {Wilson Gregory and Kaze W. K. Wong and David W. Hogg and Soledad Villar and Wilson G. Gregory},
  title = {{ginjax: E(d)-Equivariant CNN for Tensor Images}},
  journal = {J. Open Source Softw},
  year = {2025},
  doi = {10.21105/joss.08129},
}
Figure