Tensorflow.js tf.squaredDifference() Function Last Updated : 12 May, 2021 Comments Improve Suggest changes Like Article Like Report 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.squaredDifference() function is used to return (a - b) * (a - b) element-wise, where “a” is the first specified tensor and "b" is the second tensor. It Supports broadcasting. Syntax: tf.squaredDifference(a, b) Parameters: This function accepts two parameters which are illustrated below: a: The first specified tensor.b: The second specified tensor. It must have same data type as "a". Return Value: It returns (a - b) * (a - b) element-wise, where "a" is the first specified tensor and "b" is the second tensor. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Initializing two tensors const a = tf.tensor1d([1, 3, 5, 7]); const b = tf.tensor1d([1, 2, 9, 4]); // Calling the .squaredDifference() function // over the above tensor as its parameters a.squaredDifference(b).print(); Output: Tensor [0, 1, 16, 9] Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Broadcasting squared difference a with b. const a = tf.tensor1d([1, 3, 6, 7]); const b = tf.scalar(4); // Calling the .squaredDifference() function a.squaredDifference(b).print(); Output: Tensor [9, 1, 4, 9] Comment More infoAdvertise with us Next Article Tensorflow.js tf.squaredDifference() Function K Kanchan_Ray Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.square() 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.square() function is used to return the square of the specified tensor's elements. Syntax: tf.square(x) Parameters: This functi 1 min read Tensorflow.js tf.squeeze() 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 .squeeze() function is used to discard the dimensions of length one out of the shape of a stated tf.Tensor. Syntax 2 min read Tensorflow.js tf.sparseToDense() 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.sparseToDense() function is used to convert a specified sparse representation into a dense Tensor. If the given indices get rep 2 min read Tensorflow.js tf.sin() Function Tensorflow.js is an open-source library that is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .sin() function is used to find the sin of the stated tensor input, and it is done element wise. Syntax :  t 2 min read Tensorflow.js tf.metrics.meanSquaredError() 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 Tensorflow tf.metrics.meanSquaredError() function is a Loss or metric function used to  Computes the mean squared error between y_ 2 min read Tensorflow.js tf.sqrt() 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.sqrt() function is used to return the square root of the specified tensor's element. Syntax: tf.sqrt( x ) Parameters: This fun 1 min read Tensorflow.js tf.sinh() function Tensorflow.js is an open-source library which is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .sinh() function is used to find the hyperbolic sin of the stated tensor input and is done elements wise. Sy 2 min read Tensorflow.js tf.scatterND() 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 .scatterND() function is used to form a different tensor by utilizing scattered updates to the individual slices or 2 min read Tensorflow.js tf.print() 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 helps developers to develop ML models in JavaScript, and use ML directly in the browser or in Node.js. The tf.print() function is u 2 min read Tensorflow.js tf.sum() 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.sum() function is used to calculate sum of the elements of a specified Tensor across its dimension. It reduces the given input 2 min read Like