Tensorflow wavelet Layers
Project description
tensorflow-wavelets is an implementation of Custom Layers for Neural Networks:
- Discrete Wavelets Transform Layer
- Duel Tree Complex Wavelets Transform Layer
- Multi Wavelets Transform Layer
git clone https://github.com/Timorleiderman/tensorflow-wavelets.git
cd tensorflow-wavelets
pip install -r requirements.txt
Installation
tested with python 3.8
pip install tensorflow-wavelets
Usage
from tensorflow import keras
import tensorflow_wavelets.Layers.DWT as DWT
import tensorflow_wavelets.Layers.DTCWT as DTCWT
import tensorflow_wavelets.Layers.DMWT as DMWT
# Custom Activation function Layer
import tensorflow_wavelets.Layers.Threshold as Threshold
Examples
DWT(name="haar", concat=0)
"name" can be found in pywt.wavelist(family)
concat = 0 means to split to 4 smaller layers
from tensorflow import keras
model = keras.Sequential()
model.add(keras.Input(shape=(28, 28, 1)))
model.add(DWT.DWT(name="haar",concat=0))
model.add(keras.layers.Flatten())
model.add(keras.layers.Dense(nb_classes, activation="softmax"))
model.summary()
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dwt_9_haar (DWT) (None, 14, 14, 4) 0
_________________________________________________________________
flatten_9 (Flatten) (None, 784) 0
_________________________________________________________________
dense_9 (Dense) (None, 10) 7850
=================================================================
Total params: 7,850
Trainable params: 7,850
Non-trainable params: 0
_________________________________________________________________
name = "db4" concat = 1
model = keras.Sequential()
model.add(keras.layers.InputLayer(input_shape=(28, 28, 1)))
model.add(DWT.DWT(name="db4", concat=1))
model.summary()
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dwt_db4 (DWT) (None, 34, 34, 1) 0
=================================================================
Total params: 0
Trainable params: 0
Non-trainable params: 0
_________________________________________________________________
DMWT
functional example with Sure Threshold
x_inp = keras.layers.Input(shape=(512, 512, 1))
x = DMWT.DMWT("ghm")(x_inp)
x = Threshold.Threshold(algo='sure', mode='hard')(x) # use "soft" or "hard"
x = DMWT.IDMWT("ghm")(x)
model = keras.models.Model(x_inp, x, name="MyModel")
model.summary()
Model: "MyModel"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) [(None, 512, 512, 1)] 0
_________________________________________________________________
dmwt (DMWT) (None, 1024, 1024, 1) 0
_________________________________________________________________
sure_threshold (SureThreshol (None, 1024, 1024, 1) 0
_________________________________________________________________
idmwt (IDMWT) (None, 512, 512, 1) 0
=================================================================
Total params: 0
Trainable params: 0
Non-trainable params: 0
_________________________________________________________________
PyPi upload:
pip install --upgrade build
pip install --upgrade twine
python -m build
Free Software, Hell Yeah!
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file tensorflow-wavelets-1.0.29.tar.gz
.
File metadata
- Download URL: tensorflow-wavelets-1.0.29.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40740b2193ee7bfc9b07885931911e279b0227bd9b70421db2ca80a10d326932 |
|
MD5 | ae707ebf7d0c9dd04e27778521b6312e |
|
BLAKE2b-256 | 6bedf628d8499a9202bd3beb0033b6a74ad48e870ee428fbfc3f79f98fd9fa71 |
File details
Details for the file tensorflow_wavelets-1.0.29-py3-none-any.whl
.
File metadata
- Download URL: tensorflow_wavelets-1.0.29-py3-none-any.whl
- Upload date:
- Size: 25.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70d34572f5527b34310b7a1a6bf0e691dac784f8b2aa1ca4507b8921bcfb39ba |
|
MD5 | 6c71a8a65f7b76fd1ea602d9743c8b8e |
|
BLAKE2b-256 | 226d91b9620821de3894824c7bfc70cac3f08f6fec1931d50445b03dee918f4a |