DIRECTIONS
PythonDIRECTIONS = 9Classes
| Name | Description |
|---|---|
StftMagnitude |
Magnitude of a short-time Fourier transform with a fixed, stored basis |
Functions
| Name | Description |
|---|---|
max_projection |
Magnitude of complex values without a square root, within 0.25% |
DIRECTIONSconstantmax_projectionfunctionMagnitude of complex values as the largest of 9 projections of (|re|, |im|), within 0.25% in float32.StftMagnitudeclassMagnitude of a short-time Fourier transform computed as a strided convolution with a stored basis.DIRECTIONS = 9Magnitude of complex values as the largest of 9 projections of (|re|, |im|), within 0.25% in float32.
max_projection(pairs)Magnitude of complex values as the largest of 9 projections of (|re|, |im|), within 0.25% in float32.
The directions are spread from 0 to 90 degrees and scaled so the error is centred: the result is
within -0.25% and +0.25% of sqrt(re**2 + im**2). It needs no square root, so integer kernels
run it.
Parameters
| Name | Default | Description |
|---|---|---|
pairs | Required | Real and imaginary parts on the last axis, ``(..., 2)``, rank 4. |
Returns
| Description |
|---|
| The magnitudes, ``(...)``. |
Magnitude of a short-time Fourier transform computed as a strided convolution with a stored basis.
StftMagnitude( frame_length: int, frame_step: int, bins: int, padding: tuple[int, int] = (0, 0), magnitude: str = 'sqrt', **kwargs={},)Magnitude of a short-time Fourier transform computed as a strided convolution with a stored basis.
The input (batch, samples) is reflect-padded by padding (start, end) samples and convolved
with basis (frame_length taps, frame_step stride, 2 * bins filters: the real parts of
every bin, then the imaginary parts). The output is the magnitude of shape (batch, frames, bins):
sqrt(re**2 + im**2), or max_projection of (re, im). The basis is a non-trainable weight, so a
model’s window and transform travel with its weights.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
frame_length | int | Required | Samples per frame. |
frame_step | int | Required | Samples between frames. |
bins | int | Required | Frequency bins. |
padding | tuple[int, int] | (0, 0) | Samples of reflect padding before the first and after the last sample. |
magnitude | str | 'sqrt' | ``sqrt`` (exact) or ``max_projection`` (no square root, within 0.25%). |
frame_length = frame_lengthframe_step = frame_stepbins = binspadding = tuple(padding)magnitude = magnitudebuild(input_shape)call(x)compute_output_shape(input_shape)get_config()