Open In App

Tensorflow.js tf.spectral.ifft () Function

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.ifft() function is used for IFFT(Inverse Fast Fourier transform) i.e. it computes the inverse 1-dimensional DFT(discrete Fourier transform) over the inner-most dimension of the input.



Syntax:  

tf.spectral.ifft(input)

Parameters:



Return Value: It returns the result for the computation of the inverse 1-dimensional DFT(discrete Fourier transform) over the inner-most dimension of the input.

Example 1:




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Initializing a real and imaginary 1D input values
const real = tf.tensor1d([1, 5]);
const imag = tf.tensor1d([2, 4]);
const x = tf.complex(real, imag);
  
// Calling the .spectral.ifft() function
// over the input parameter value x
tf.spectral.ifft(x).print();

Output:

Tensor
   [3 + 3j, -2 + -1j]

Example 2:




// Importing the tensorflow library
import * as tf from "@tensorflow/tfjs"
  
// Using a real and imaginary 1D input values as the
// parameter for the .complex() function
const x = tf.complex(tf.tensor1d([5, 10, 15, 20]), tf.tensor1d([1, 2, 3, 4]));
  
// Calling the .spectral.ifft() function
// over the input parameter value x
tf.spectral.ifft(x).print();

Output:

Tensor
   [12.5 + 2.5j, -2 + -3j, -2.5 + -0.5j, -3 + 2j]

Reference: https://js.tensorflow.org/api/latest/#spectral.ifft

Article Tags :