Tensorflow.js tf.imag() Function
Last Updated :
18 May, 2021
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
import * as tf from "@tensorflow/tfjs"
const y = tf.complex([-21, 30], [14, 5]);
tf.imag(y).print();
|
Output:
Tensor
[14, 5]
Example 2:
Javascript
import * as tf from "@tensorflow/tfjs"
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
Share your thoughts in the comments
Please Login to comment...