Package: tensorflow-wavelets
tensorflow-wavelets is an implementation of Custom Layers for Neural Networks:Discrete Wavelets Transform LayerDuel Tree Complex Wavelets Transform LayerMulti Wavelets Transform Layergit clone https://github.com/Timorleiderman/tensorflow-wavelets.git
cd tensorflow-wavelets
pip install -r requirements.txtInstallationtested with python 3.8pip install tensorflow-waveletsUsagefrom 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 ThresholdExamplesDWT(name="haar", concat=0)"name" can be found in pywt.wavelist(family)concat = 0 means to split to 4 smaller layersfrom 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 = 1model = 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
_________________________________________________________________DMWTfunctional example with Sure Thresholdx_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 buildFree Software, Hell Yeah!