Skip to content
Related Articles

Related Articles

Improve Article

Tensorflow.js tf.spectral.irfft () 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.irfft() function is used for IRFFT(Inversed real value input Fast Fourier transform) i.e. it computes the 1-dimensional IDFT(Inversed discrete Fourier transform) over the inner-most dimension of the real input value.

Syntax:  

tf.spectral.irfft(input)

Parameters:

  • input: The complex input on which an irfft is being performed.

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



Example 1:

Javascript




// 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.irfft() function
// over the parameter input real value x
tf.spectral.irfft(x).print();

Output:

Tensor
    [[3, -2],]

Example 2:

Javascript




// 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([1, 2, 3, 4]), 
                     tf.tensor1d([2, 4, 6, 8]));
  
// Calling the .spectral.irfft() function
// over the input parameter value x
tf.spectral.irfft(x).print();

Output:

Tensor
    [[2.5, -3.5534179, 0.5773503, -0.1666667, -0.5773499, 2.2200849],]

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :