Skip to content

Boundary conditions (circulant, mirror, reflect) and real transforms (dct, dst) in PyTorch

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE-CUPY
Notifications You must be signed in to change notification settings

balbasty/torch-bounds

Repository files navigation

torch-bounds

Boundary conditions (circulant, mirror, reflect) and real transforms (DCT, DST) in PyTorch.

Overview

This small package implements a wide range of boundary conditions used to extrapolate a given discrete signal outside of its native bounds.

Based on these additional boundary conditions, it implements:

  • pad: an extension of torch.nn.functional.pad
  • roll: an extension of torch.roll

It also implements discrete sine and cosine transforms (variants 1, 2 and 3), using a trick similar to cupy.

Finally, it implements additional utilities:

  • ensure_shape crops or pads a tensor (with any boundary condition) so that it matches a give shape.
  • indexing is a module that implements functions to tranforms out-of-bounds coordinates into in-bounds coordinates according to any boundary condition.
  • types is a module that defines names and aliases for different boundary conditions, as well as tools to convert between different naming conventions.

Documentation

See our documentation and notebooks.

Installation

Dependency

  • torch >= 1.3
  • torch >= 1.8 if real transforms are needed (dct, dst)

Conda

conda install torch-bounds -c balbasty -c pytorch

Pip

pip install torch-bounds

Related packages

  • torch-interpol: B-spline interpolation with the same boundary conditions as those implemented here.
  • torch-distmap: Euclidean distance transform.

About

Boundary conditions (circulant, mirror, reflect) and real transforms (dct, dst) in PyTorch

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE-CUPY

Stars

Watchers

Forks

Packages

No packages published

Languages