Tensorflow.js tf.spectral.rfft () Function
Last Updated :
10 May, 2021
Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment.
The tf.spectral.rfft() function is used for RFFT(real value input Fast Fourier transform) i.e. it computes the 1-dimensional DFT(Discrete Fourier transform) over the inner-most dimension of the real input value.
Syntax:
tf.spectral.rfft(input, fftLength)
Parameters:
- input: The complex input on which an rfft is being performed.
- fftLength: It is an optional parameter.
Return Value: It returns the result for the computation of the 1-dimensional DFT(Discrete Fourier transform) over the inner-most dimension of the real input value.
Example 1:
Javascript
import * as tf from "@tensorflow/tfjs"
const real = tf.tensor1d([2, 4, 6]);
real.rfft().print();
|
Output:
Tensor
[12 + 0j, -2.999999 + 1.7320514j]
Example 2:
Javascript
import * as tf from "@tensorflow/tfjs"
tf.tensor1d([1, 2, 3, 4]).rfft().print();
|
Output:
Tensor
[10 + 0j, -2 + 2j, -2 + 0j]
Reference: https://js.tensorflow.org/api/latest/#spectral.rfft
Share your thoughts in the comments
Please Login to comment...