Kymatio python package

Kymatio is a Python module for computing wavelet and scattering transforms.

It is built on top of PyTorch, but also has a fast CUDA backend via cupy and skcuda.

Use kymatio if you need a library that:

  • integrates wavelet scattering in a deep learning architecture,
  • supports 1-D, 2-D, and 3-D wavelets, and runs seamlessly on CPU and GPU hardware.
  • A brief intro to wavelet scattering is provided in User Guide. For a list of publications see Publications.

Quick Start

On Linux or macOS, open a shell and run the instruction of kymatio.

In the Python intepreter, you may then call:

import kymatio

which should run without error if the package has been correctly installed.

Apply 2D scattering to a 32x32 random image

The following code imports torch and the Scattering2D class, which implements the 2D scattering transform. It then creates an instance of this class to compute the scattering transform at scale J = 2 of a 32x32 image consisting of Gaussian white noise:

import torch
from kymatio import Scattering2D
scattering = Scattering2D(J=2, shape=(32, 32))
x = torch.randn(1, 1, 32, 32)
Sx = scattering(x)

This should output:

torch.Size([1, 1, 81, 8, 8])

This corresponds to 81 scattering coefficients, each corresponding to an 8x8 image.

Check out the User Guide for more scattering transform examples.


comments powered by Disqus