Differentiable and GPU-enabled fast wavelet transforms in JAX.
Features
1d analysis and synthesis transforms are implemented in src/jaxwt/conv_fwt.py. Try wavedec and waverec.
2d analysis and synthesis transforms are part of the src/jaxwt/conv_fwt_2d.py module. The two functions are called wavedec2 and waverec2.
Furthermore, 3d transforms are provided by the wavedec3 and waverec3 functions.
cwt-function supports 1d continuous wavelet transforms.
The WaveletPacket object supports 1d wavelet packet transforms.
WaveletPacket2d implements two-dimensional wavelet packet transforms.
swt computes a single dimensional stationary transform iswt inverts it.
This toolbox extends PyWavelets . jaxwt additionally provides GPU and gradient support via a Jax backend.
Installation
To install Jax, head over to https://github.com/google/jax#installation and follow the procedure described there. Afterward, type pip install jaxwt to install the Jax-Wavelet-Toolbox. You can uninstall it later by typing pip uninstall jaxwt.
Documentation
The documentation is available at: https://jax-wavelet-toolbox.readthedocs.io/en/latest/jaxwt.html .
Transform Examples:
One-dimensional fast wavelet transform:
import pywt
import numpy as np;
import jax.numpy as jnp
import jaxwt as jwt
# generate an input of even length.
data = jnp.array([0., 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0])
wavelet = pywt.Wavelet('haar')
# compare the forward fwt coefficients
print(pywt.wavedec(np.array(data), wavelet, mode='zero', level=2))
print(jwt.wavedec(data, wavelet, mode='zero', level=2))
# invert the fwt.
print(jwt.waverec(jwt.wavedec(data, wavelet, mode='zero', level=2),
wavelet))
Two-dimensional fast wavelet transform:
import pywt, scipy.datasets
import jaxwt as jwt
import jax.numpy as jnp
face = jnp.transpose(
scipy.datasets.face(), [2, 0, 1]).astype(jnp.float64)
transformed = jwt.wavedec2(face, pywt.Wavelet("haar"),
level=2, mode="reflect")
reconstruction = jwt.waverec2(transformed, pywt.Wavelet("haar"))
jnp.max(jnp.abs(face - reconstruction))
Testing
Unit tests are handled by nox. Clone the repository and run it with the following:
$ pip install nox
$ git clone https://github.com/v0lta/Jax-Wavelet-Toolbox
$ cd Jax-Wavelet-Toolbox
$ nox -s test
Goals
In the spirit of Jax, the aim is to be 100% pywt compatible. Whenever possible, interfaces should be the same results identical.
64-Bit floating-point numbers
If you need 64-bit floating point support, set the Jax config flag:
from jax.config import config
config.update("jax_enable_x64", True)
Citation
If you use this work in a scientific context, please cite:
@phdthesis{handle:20.500.11811/9245,
urn: https://nbn-resolving.org/urn:nbn:de:hbz:5-63361,
author = {{Moritz Wolter}},
title = {Frequency Domain Methods in Recurrent Neural Networks for Sequential Data Processing},
school = {Rheinische Friedrich-Wilhelms-Universität Bonn},
year = 2021,
month = jul,
url = {https://hdl.handle.net/20.500.11811/9245}
}
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jaxwt-0.1.0.tar.gz.
File metadata
- Download URL: jaxwt-0.1.0.tar.gz
- Upload date:
- Size: 27.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c97630d09014a6d62c4d60b113dda8113dba91d226dfd80f6b880eab6fc8dd7
|
|
| MD5 |
f717debc7eba56e524c1512dd4de3aa5
|
|
| BLAKE2b-256 |
59fdaf2cff2ad02db8c851ca96b77d978e50e8ecf8467ab872e672134bf90ac3
|
File details
Details for the file jaxwt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jaxwt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 37.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e81b271a4a562e10c240e6329aed1bd23da2303118a768131a9bdfcd3755bd3f
|
|
| MD5 |
d4febbd5fe62a571af05a566be97b9eb
|
|
| BLAKE2b-256 |
2af330716280cc026796ce5d46566ffc5b0663d6ca91a9b3a87abe3304d1b3e3
|