Sunday, November 17, 2024
Google search engine
HomeLanguagesJavascriptTensorflow.js tf.imag() Function

Tensorflow.js tf.imag() Function

Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment.

The .imag() function is used to find the imaginary section of the stated complex or a real tensor input. Moreover, if the stated tensor input is real then there is no imaginary part, so tensor of all zeroes is returned as output.

Syntax :  

tf.imag(input)

Parameters:  

  • input: It is the stated tensor input, and it can be of type tf.Tensor, TypedArray, or Array.

Return Value: It returns the tf.Tensor object.

Example 1:  

Javascript




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Defining tensor input elements
const y = tf.complex([-21, 30], [14, 5]);
  
// Calling imag() method and
// Printing output
tf.imag(y).print();


Output:

Tensor
    [14, 5]

Example 2:

Javascript




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Calling imag() method and
// Printing output
tf.imag(tf.complex([-2.1, 3.0], [1.65, 57.5])).print();


Output:

Tensor
    [1.65, 57.5]

Reference: https://js.tensorflow.org/api/latest/#imag

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments