jaxwt


Namejaxwt JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/v0lta/Jax-Wavelet-Toolbox
SummaryDifferentiable and gpu enabled fast wavelet transforms in JAX
upload_time2024-02-13 10:41:18
maintainerMoritz Wolter
docs_urlNone
authorMoritz Wolter
requires_python>=3.9
licenseEUPL-1.2
keywords wavelets wavelet transform fast wavelet transform jax
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. |favicon| image:: https://raw.githubusercontent.com/v0lta/Jax-Wavelet-Toolbox/master/docs/favicon/favicon.ico
    :alt: Shannon-wavelet favicon
    :width: 32
    :target: https://pypi.org/project/jaxwt/

*************************************
|favicon| Jax Wavelet Toolbox (jaxwt)
*************************************


.. image:: https://github.com/v0lta/Jax-Wavelet-Toolbox/actions/workflows/tests.yml/badge.svg 
    :target: https://github.com/v0lta/Jax-Wavelet-Toolbox/actions/workflows/tests.yml
    :alt: GitHub Actions

.. image:: https://readthedocs.org/projects/jax-wavelet-toolbox/badge/?version=latest
    :target: https://jax-wavelet-toolbox.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation Status

.. image:: https://img.shields.io/pypi/pyversions/jaxwt
    :target: https://pypi.org/project/jaxwt/
    :alt: PyPI Versions

.. image:: https://img.shields.io/pypi/v/jaxwt
    :target: https://pypi.org/project/jaxwt/
    :alt: PyPI - Project

.. image:: https://img.shields.io/pypi/l/jaxwt
    :target: https://github.com/v0lta/Jax-Wavelet-Toolbox/blob/master/LICENSE
    :alt: PyPI - License

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black
    :alt: Black code style

.. image:: https://static.pepy.tech/personalized-badge/jaxwt?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads
    :target: https://pepy.tech/project/jaxwt
    :alt: PyPi - downloads


Differentiable and GPU-enabled fast wavelet transforms in JAX. 

Features
""""""""
- ``wavedec`` and ``waverec`` implement 1d analysis and synthesis transforms.
- Similarly, ``wavedec2`` and ``waverec2`` provide 2d transform support.
- The ``cwt``-function supports 1d continuous wavelet transforms.
- The ``WaveletPacket`` object supports 1d wavelet packet transforms.
- ``WaveletPacket2d`` implements two-dimensional wavelet packet transforms.
- ``swt`` and ``iswt`` allow 1d-stationary transformations.

This toolbox extends `PyWavelets <https://pywavelets.readthedocs.io/en/latest/>`_. 
We additionally provide 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
"""""""""""""
Complete documentation of all toolbox functions is available at
`readthedocs <https://jax-wavelet-toolbox.readthedocs.io/en/latest/jaxwt.html>`_.


Transform Examples:
"""""""""""""""""""

To compute a one-dimensional fast wavelet transform, consider the code snippet below:

.. code-block:: python

  import jax.numpy as jnp
  import jaxwt as jwt

  import pywt
  import numpy as np;

  # 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])
  
  # compare the forward fwt coefficients
  print(pywt.wavedec(np.array(data), 'haar', mode='zero', level=2))
  print(jwt.wavedec(data, 'haar', mode='zero', level=2))
  
  # invert the fwt.
  print(jwt.waverec(jwt.wavedec(data, 'haar', mode='zero', level=2),
                    'haar'))


The snipped also evaluates the `pywt` implementation to demonstrate that the coefficients are the same.
Use `jaxwt` if you require gradient or GPU support.

The process for two-dimensional fast wavelet transforms works similarly:

.. code-block:: python

  import jaxwt as jwt
  import jax.numpy as jnp
  from scipy.datasets import face

  image = jnp.transpose(
      face(), [2, 0, 1]).astype(jnp.float32)
  transformed = jwt.wavedec2(image, "haar", 
                             level=2, mode="reflect")
  reconstruction = jwt.waverec2(transformed, "haar")
  jnp.max(jnp.abs(image - reconstruction))


``jaxwt`` allows transforming batched data.
The example above moves the color channel to the front because wavedec2 transforms the last two axes by default.
We can avoid doing so by using the ``axes`` argument. Consider the batched example below:

.. code-block:: python

  import jaxwt as jwt
  import jax.numpy as jnp
  from scipy.datasets import face

  image = jnp.stack(
      [face(), face(), face()], axis=0
       ).astype(jnp.float32)
  transformed = jwt.wavedec2(image, "haar", 
                             level=2, mode="reflect",
                             axes=(1,2))
  reconstruction = jwt.waverec2(transformed, "haar", axes=(1,2))
  jnp.max(jnp.abs(image - reconstruction))


For more code examples, follow the documentation link above or visit
the `examples <https://github.com/v0lta/Jax-Wavelet-Toolbox/tree/master/examples>`_ folder.



Testing
"""""""
Unit tests are handled by ``nox``. Clone the repository and run it with the following:

.. code-block:: sh

    $ 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: 

.. code-block:: python

    from jax.config import config
    config.update("jax_enable_x64", True)


Citation
"""""""""""

If you use this work in a scientific context, please cite the following:

.. code-block::

  @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}
  }

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/v0lta/Jax-Wavelet-Toolbox",
    "name": "jaxwt",
    "maintainer": "Moritz Wolter",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "moritz@wolter.tech",
    "keywords": "Wavelets,Wavelet Transform,Fast Wavelet Transform,Jax",
    "author": "Moritz Wolter",
    "author_email": "moritz@wolter.tech",
    "download_url": "https://files.pythonhosted.org/packages/8e/17/c84e28e78bfb3b626977390e915b563d940b7c06a7f15739834071f713a4/jaxwt-0.1.1.tar.gz",
    "platform": null,
    "description": ".. |favicon| image:: https://raw.githubusercontent.com/v0lta/Jax-Wavelet-Toolbox/master/docs/favicon/favicon.ico\n    :alt: Shannon-wavelet favicon\n    :width: 32\n    :target: https://pypi.org/project/jaxwt/\n\n*************************************\n|favicon| Jax Wavelet Toolbox (jaxwt)\n*************************************\n\n\n.. image:: https://github.com/v0lta/Jax-Wavelet-Toolbox/actions/workflows/tests.yml/badge.svg \n    :target: https://github.com/v0lta/Jax-Wavelet-Toolbox/actions/workflows/tests.yml\n    :alt: GitHub Actions\n\n.. image:: https://readthedocs.org/projects/jax-wavelet-toolbox/badge/?version=latest\n    :target: https://jax-wavelet-toolbox.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\n.. image:: https://img.shields.io/pypi/pyversions/jaxwt\n    :target: https://pypi.org/project/jaxwt/\n    :alt: PyPI Versions\n\n.. image:: https://img.shields.io/pypi/v/jaxwt\n    :target: https://pypi.org/project/jaxwt/\n    :alt: PyPI - Project\n\n.. image:: https://img.shields.io/pypi/l/jaxwt\n    :target: https://github.com/v0lta/Jax-Wavelet-Toolbox/blob/master/LICENSE\n    :alt: PyPI - License\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :target: https://github.com/psf/black\n    :alt: Black code style\n\n.. image:: https://static.pepy.tech/personalized-badge/jaxwt?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads\n    :target: https://pepy.tech/project/jaxwt\n    :alt: PyPi - downloads\n\n\nDifferentiable and GPU-enabled fast wavelet transforms in JAX. \n\nFeatures\n\"\"\"\"\"\"\"\"\n- ``wavedec`` and ``waverec`` implement 1d analysis and synthesis transforms.\n- Similarly, ``wavedec2`` and ``waverec2`` provide 2d transform support.\n- The ``cwt``-function supports 1d continuous wavelet transforms.\n- The ``WaveletPacket`` object supports 1d wavelet packet transforms.\n- ``WaveletPacket2d`` implements two-dimensional wavelet packet transforms.\n- ``swt`` and ``iswt`` allow 1d-stationary transformations.\n\nThis toolbox extends `PyWavelets <https://pywavelets.readthedocs.io/en/latest/>`_. \nWe additionally provide GPU and gradient support via a Jax backend.\n\nInstallation\n\"\"\"\"\"\"\"\"\"\"\"\"\nTo install Jax, head over to https://github.com/google/jax#installation and follow the procedure described there.\nAfterward, type ``pip install jaxwt`` to install the Jax-Wavelet-Toolbox. You can uninstall it later by typing ``pip uninstall jaxwt``.\n\nDocumentation\n\"\"\"\"\"\"\"\"\"\"\"\"\"\nComplete documentation of all toolbox functions is available at\n`readthedocs <https://jax-wavelet-toolbox.readthedocs.io/en/latest/jaxwt.html>`_.\n\n\nTransform Examples:\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\nTo compute a one-dimensional fast wavelet transform, consider the code snippet below:\n\n.. code-block:: python\n\n  import jax.numpy as jnp\n  import jaxwt as jwt\n\n  import pywt\n  import numpy as np;\n\n  # generate an input of even length.\n  data = jnp.array([0., 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0])\n  \n  # compare the forward fwt coefficients\n  print(pywt.wavedec(np.array(data), 'haar', mode='zero', level=2))\n  print(jwt.wavedec(data, 'haar', mode='zero', level=2))\n  \n  # invert the fwt.\n  print(jwt.waverec(jwt.wavedec(data, 'haar', mode='zero', level=2),\n                    'haar'))\n\n\nThe snipped also evaluates the `pywt` implementation to demonstrate that the coefficients are the same.\nUse `jaxwt` if you require gradient or GPU support.\n\nThe process for two-dimensional fast wavelet transforms works similarly:\n\n.. code-block:: python\n\n  import jaxwt as jwt\n  import jax.numpy as jnp\n  from scipy.datasets import face\n\n  image = jnp.transpose(\n      face(), [2, 0, 1]).astype(jnp.float32)\n  transformed = jwt.wavedec2(image, \"haar\", \n                             level=2, mode=\"reflect\")\n  reconstruction = jwt.waverec2(transformed, \"haar\")\n  jnp.max(jnp.abs(image - reconstruction))\n\n\n``jaxwt`` allows transforming batched data.\nThe example above moves the color channel to the front because wavedec2 transforms the last two axes by default.\nWe can avoid doing so by using the ``axes`` argument. Consider the batched example below:\n\n.. code-block:: python\n\n  import jaxwt as jwt\n  import jax.numpy as jnp\n  from scipy.datasets import face\n\n  image = jnp.stack(\n      [face(), face(), face()], axis=0\n       ).astype(jnp.float32)\n  transformed = jwt.wavedec2(image, \"haar\", \n                             level=2, mode=\"reflect\",\n                             axes=(1,2))\n  reconstruction = jwt.waverec2(transformed, \"haar\", axes=(1,2))\n  jnp.max(jnp.abs(image - reconstruction))\n\n\nFor more code examples, follow the documentation link above or visit\nthe `examples <https://github.com/v0lta/Jax-Wavelet-Toolbox/tree/master/examples>`_ folder.\n\n\n\nTesting\n\"\"\"\"\"\"\"\nUnit tests are handled by ``nox``. Clone the repository and run it with the following:\n\n.. code-block:: sh\n\n    $ pip install nox\n    $ git clone https://github.com/v0lta/Jax-Wavelet-Toolbox\n    $ cd Jax-Wavelet-Toolbox\n    $ nox -s test\n\nGoals\n\"\"\"\"\"\n- In the spirit of Jax, the aim is to be 100% pywt compatible. Whenever possible, interfaces should be the same\n  results identical.\n\n\n64-Bit floating-point numbers\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\nIf you need 64-bit floating point support, set the Jax config flag: \n\n.. code-block:: python\n\n    from jax.config import config\n    config.update(\"jax_enable_x64\", True)\n\n\nCitation\n\"\"\"\"\"\"\"\"\"\"\"\n\nIf you use this work in a scientific context, please cite the following:\n\n.. code-block::\n\n  @phdthesis{handle:20.500.11811/9245,\n    urn: https://nbn-resolving.org/urn:nbn:de:hbz:5-63361,\n    author = {{Moritz Wolter}},\n    title = {Frequency Domain Methods in Recurrent Neural Networks for Sequential Data Processing},\n    school = {Rheinische Friedrich-Wilhelms-Universit\u00e4t Bonn},\n    year = 2021,\n    month = jul,\n    url = {https://hdl.handle.net/20.500.11811/9245}\n  }\n",
    "bugtrack_url": null,
    "license": "EUPL-1.2",
    "summary": "Differentiable and gpu enabled fast wavelet transforms in JAX",
    "version": "0.1.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/v0lta/Jax-Wavelet-Toolbox/issues",
        "Download": "https://github.com/v0lta/Jax-Wavelet-Toolbox/releases",
        "Homepage": "https://github.com/v0lta/Jax-Wavelet-Toolbox",
        "Source Code": "https://github.com/v0lta/Jax-Wavelet-Toolbox"
    },
    "split_keywords": [
        "wavelets",
        "wavelet transform",
        "fast wavelet transform",
        "jax"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2131cb87159d6e1f746b41a0f158cd3fc64e9fbd5237823b256259db9192b6b7",
                "md5": "67288e75fd3ccb09623897271023e5b9",
                "sha256": "465844856b53d7f2dfaeafdd84b51a64b69ee8d300cd2498748b7c146cc24d5b"
            },
            "downloads": -1,
            "filename": "jaxwt-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "67288e75fd3ccb09623897271023e5b9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 26868,
            "upload_time": "2024-02-13T10:41:16",
            "upload_time_iso_8601": "2024-02-13T10:41:16.022963Z",
            "url": "https://files.pythonhosted.org/packages/21/31/cb87159d6e1f746b41a0f158cd3fc64e9fbd5237823b256259db9192b6b7/jaxwt-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8e17c84e28e78bfb3b626977390e915b563d940b7c06a7f15739834071f713a4",
                "md5": "bc78f0f91d8afb889e507d68d47eb8bd",
                "sha256": "672c394e979ac517625121bb6196b51cc3d41547668354c081f7d7ed274589dd"
            },
            "downloads": -1,
            "filename": "jaxwt-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "bc78f0f91d8afb889e507d68d47eb8bd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 28475,
            "upload_time": "2024-02-13T10:41:18",
            "upload_time_iso_8601": "2024-02-13T10:41:18.485032Z",
            "url": "https://files.pythonhosted.org/packages/8e/17/c84e28e78bfb3b626977390e915b563d940b7c06a7f15739834071f713a4/jaxwt-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-13 10:41:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "v0lta",
    "github_project": "Jax-Wavelet-Toolbox",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "jaxwt"
}
        
Elapsed time: 0.17760s