tf.keras.ops.stft
Stay organized with collections
Save and categorize content based on your preferences.
Short-Time Fourier Transform along the last axis of the input.
tf.keras.ops.stft(
x,
sequence_length,
sequence_stride,
fft_length,
window='hann',
center=True
)
The STFT computes the Fourier transform of short overlapping windows of the
input. This giving frequency components of the signal as they change over
time.
Args |
x
|
Input tensor.
|
sequence_length
|
An integer representing the sequence length.
|
sequence_stride
|
An integer representing the sequence hop size.
|
fft_length
|
An integer representing the size of the FFT to apply. If not
specified, uses the smallest power of 2 enclosing sequence_length .
|
window
|
A string, a tensor of the window or None . If window is a
string, available values are "hann" and "hamming" . If window
is a tensor, it will be used directly as the window and its length
must be sequence_length . If window is None , no windowing is
used. Defaults to "hann" .
|
center
|
Whether to pad x on both sides so that the t-th sequence is
centered at time t * sequence_stride . Otherwise, the t-th sequence
begins at time t * sequence_stride . Defaults to True .
|
Returns |
A tuple containing two tensors - the real and imaginary parts of the
STFT output.
|
Example:
x = keras.ops.convert_to_tensor([0.0, 1.0, 2.0, 3.0, 4.0])
stft(x, 3, 2, 3)
(array([[0.75, -0.375],
[3.75, -1.875],
[5.25, -2.625]]), array([[0.0, 0.64951905],
[0.0, 0.64951905],
[0.0, -0.64951905]]))
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-06-07 UTC.
[null,null,["Last updated 2024-06-07 UTC."],[],[],null,["# tf.keras.ops.stft\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/keras-team/keras/tree/v3.3.3/keras/src/ops/math.py#L656-L710) |\n\nShort-Time Fourier Transform along the last axis of the input. \n\n tf.keras.ops.stft(\n x,\n sequence_length,\n sequence_stride,\n fft_length,\n window='hann',\n center=True\n )\n\nThe STFT computes the Fourier transform of short overlapping windows of the\ninput. This giving frequency components of the signal as they change over\ntime.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `x` | Input tensor. |\n| `sequence_length` | An integer representing the sequence length. |\n| `sequence_stride` | An integer representing the sequence hop size. |\n| `fft_length` | An integer representing the size of the FFT to apply. If not specified, uses the smallest power of 2 enclosing `sequence_length`. |\n| `window` | A string, a tensor of the window or `None`. If `window` is a string, available values are `\"hann\"` and `\"hamming\"`. If `window` is a tensor, it will be used directly as the window and its length must be `sequence_length`. If `window` is `None`, no windowing is used. Defaults to `\"hann\"`. |\n| `center` | Whether to pad `x` on both sides so that the t-th sequence is centered at time `t * sequence_stride`. Otherwise, the t-th sequence begins at time `t * sequence_stride`. Defaults to `True`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A tuple containing two tensors - the real and imaginary parts of the STFT output. ||\n\n\u003cbr /\u003e\n\n#### Example:\n\n x = keras.ops.convert_to_tensor([0.0, 1.0, 2.0, 3.0, 4.0])\n stft(x, 3, 2, 3)\n (array([[0.75, -0.375],\n [3.75, -1.875],\n [5.25, -2.625]]), array([[0.0, 0.64951905],\n [0.0, 0.64951905],\n [0.0, -0.64951905]]))"]]