View source on GitHub
|
Initializer of Conv kernels for Short-term Fourier Transformation (STFT).
Inherits From: Initializer
tf.keras.initializers.STFT(
side='real',
window='hann',
scaling='density',
periodic=False
)
Since the formula involves complex numbers, this class compute either the real or the imaginary components of the final output.
Additionally, this initializer supports windowing functions across the time
dimension as commonly used in STFT. Windowing functions from the module
scipy.signal.windows are supported, including the common hann and
hamming windowing functions. This layer supports periodic windows and
scaling-based normalization.
This is primarily intended for use in the STFTSpectrogram layer.
Examples:
# Standalone usage:initializer = STFTInitializer("real", "hann", "density", False)values = initializer(shape=(128, 1, 513))
Methods
clone
clone()
from_config
@classmethodfrom_config( config )
Instantiates an initializer from a configuration dictionary.
Example:
initializer = RandomUniform(-1, 1)
config = initializer.get_config()
initializer = RandomUniform.from_config(config)
| Args | |
|---|---|
config
|
A Python dictionary, the output of get_config().
|
| Returns | |
|---|---|
An Initializer instance.
|
get_config
get_config()
Returns the initializer's configuration as a JSON-serializable dict.
| Returns | |
|---|---|
| A JSON-serializable Python dict. |
__call__
__call__(
shape, dtype=None
)
Returns a tensor object initialized as specified by the initializer.
The shape is assumed to be (T, 1, F // 2 + 1), where T is the size
of the given window, and F is the number of frequency bands. Only half
the frequency bands are used, which is a common practice in STFT,
because the second half are the conjugates of the first half in
a reversed order.
| Args | |
|---|---|
shape
|
Shape of the tensor. |
dtype
|
Optional dtype of the tensor. Only numeric or boolean dtypes
are supported. If not specified, keras.backend.floatx()
is used, which default to float32 unless you configured it
otherwise (via keras.backend.set_floatx(float_dtype)).
|
View source on GitHub