Tensorflow.js tf.sqrt() 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.sqrt() function is used to return the square root of the specified tensor’s element.
Syntax:
tf.sqrt( x )
Parameters: This function accept single parameter which is illustrated below:
- x: The specified input tensor.
Return Value: It returns the square root of the specified tensor’s element.
Example 1:
Javascript
import * as tf from "@tensorflow/tfjs"
const x = tf.tensor1d([4, 9, 16, 25]);
x.sqrt().print();
|
Output:
Tensor
[2, 3, 4, 5]
Example 2:
Javascript
import * as tf from "@tensorflow/tfjs"
tf.tensor1d([0, 1, 2, 1.7, 2.5]).sqrt().print();
|
Output:
Tensor
[0, 1, 1.4142135, 1.3038405, 1.5811388]
Share your thoughts in the comments
Please Login to comment...