Tensorflow.js tf.imag() Function Last Updated : 18 May, 2021 Comments Improve Suggest changes Like Article Like Report 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 Comment More infoAdvertise with us Next Article Tensorflow.js tf.imag() Function nidhi1352singh Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.grad() 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.grad() function is used to return the gradient of the specified function f(x) with respect to x. Syntax: Â tf.grad (f) Paramete 2 min read Tensorflow.js tf.grads() 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. It also helps the developers to develop ML models in JavaScript language and can use ML directly in the browser or in Node.js. The tf. 1 min read Tensorflow.js tf.gather() 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 .gather() function is used to collect the fragments from the stated tensor x's axis as per the stated indices. Synt 2 min read Tensorflow.js tf.eye() Function Tensorflow.js is an open-source library for creating machine learning models in Javascript that allows users to run the models directly in the browser. The tf.eye() is a function defined in the class tf.Tensor. Itâs used to create an identity matrix of specified rows and columns. An identity matrix 3 min read Tensorflow.js tf.pad() 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. It also helps the developers to develop ML models in JavaScript language and can use ML directly in the browser or in Node.js. The tf. 2 min read Like