Giter Club home page Giter Club logo

wavetf's Introduction

WaveTF: a 1D and 2D wavelet library for TensorFlow and Keras

Overview

WaveTF is a TensorFlow library which implements 1D and 2D wavelet transforms, making them available as Keras layers, which can thus be easily plugged into machine learning workflows.

WaveTF can also be used outside of machine learning contexts, as a parallel wavelet computation tool, running on CPUs, GPUs or Google Cloud TPUs, and supporting, transparently at runtime, both 32- and 64-bit floats.

It accepts batched, multichannel inputs, e.g., for the 2D case, inputs of shape [batch_size, dim_x, dim_y, channels]. Currently, Haar and Daubechies-N=2 wavelet kernels are supported, and the input signal is extended via anti-symmetric-reflect padding, which preserves its first order finite difference at the border.

Installation

Install with pip:

$ pip3 install .

Requirements

WaveTF requires TensorFlow 2 to be installed. If you want to run the tests you will also need pytest, numpy and PyWavelets.

Documentation

API documentation for the latest WaveTF version is available via ReadTheDocs.

Generation via Sphinx

Alternatively, it can be generated locally via Sphinx.

To install Sphinx:

$ pip3 install sphinx sphinx_rtd_theme

To generate the html documentation (accessible at location docs/build/html/index.html):

$ make -C docs/ html

Further details

An article describing in detail WaveTF's implementation and performance has been presented at the CADL workshop at ICPR 2020 and is available either via the Springer website or the CRS4 publications repository (direct link to PDF).

Citation

@InProceedings{wavetf,
  author="Versaci, Francesco",
  title="WaveTF: A Fast 2D Wavelet Transform for Machine Learning in Keras",
  booktitle="Pattern Recognition. ICPR International Workshops and Challenges",
  year="2021",
  publisher="Springer International Publishing",
  pages="605--618",
  isbn="978-3-030-68763-2"
}

Usage

WaveTF directly exposes a single class, which is a factory for Keras layers which implement the Haar and Daubechies-N=2 wavelet transforms and anti-transforms. Its use is pretty straightforward.

import tensorflow as tf
from wavetf import WaveTFFactory

# input tensor
t0 = tf.random.uniform([32, 300, 200, 3])
# transform
w = WaveTFFactory().build('db2', dim=2)
t1 = w.call(t0)
# anti-transform
w_i = WaveTFFactory().build('db2', dim=2, inverse=True)
t2 = w_i.call(t1)
# compute difference
delta = abs(t2-t0)
print(f'Precision error: {tf.math.reduce_max(delta)}')

Examples

Some basic examples, including a simple wavelet-enriched Convolutional Neural Network (CNN), are available in the examples directory.

Author

WaveTF is developed by

License

WaveTF is licensed under the Apache License, Version 2.0. See LICENSE for further details.

wavetf's People

Contributors

fversaci avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.