TensorFlow GPU & TPU compatible operations: MelSpectrogram, TimeFreqMask, CutMix, MixUp, ZScore, and more
For Stable version
!pip install tensorflow-extra
or For updated version
!pip install git+https://github.com/awsaf49/tensorflow_extra
To check use case of this library, checkout BirdCLEF23: Pretraining is All you Need notebook. It uses this library along with Multi Stage Transfer Learning for Bird Call Identification task.
Converts audio data to mel-spectrogram in GPU/TPU.
import tensorflow_extra as tfe
audio2spec = tfe.layers.MelSpectrogram()
spec = audio2spec(audio)
Can also control number of stripes.
time_freq_mask = tfe.layers.TimeFreqMask()
spec = time_freq_mask(spec)
Can be used with audio, spec, image. For spec full freq resolution can be used using full_height=True
.
cutmix = tfe.layers.CutMix()
audio = cutmix(audio, training=True) # accepts both audio & spectrogram
Can be used with audio, spec, image. For spec full freq resolution can be used using full_height=True
.
mixup = tfe.layers.MixUp()
audio = mixup(audio, training=True) # accepts both audio & spectrogram
Applies standardization and rescaling.
norm = tfe.layers.ZScoreMinMax()
spec = norm(spec)
import tensorflow as tf
import tensorflow_extra as tfe
a = tf.constant([-2.5, -1.0, 0.5, 1.0, 2.5])
b = tfe.activations.smelu(a) # array([0., 0.04166667, 0.6666667 , 1.0416666 , 2.5])