Tensorflow.js tf.sign() 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 .sign() function is used to find the indication of the stated sign of a given number and is done element wise. Syntax : tf.sign(x) Parameters: x: 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.tensor1d([1, 7.6, 0, NaN, -4, .91]); // Calling sign() method and // Printing output y.sign().print(); Output: Tensor [1, 1, 0, 0, -1, 1] Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Defining tensor input var val = [1.5, .4, .22, null, 'a']; // Calling tensor1d method const y = tf.tensor1d(val); // Calling sign() method var res = tf.sign(y) // Printing output res.print(); Output: Tensor [1, 1, 1, 0, 0] Reference: https://js.tensorflow.org/api/latest/#sign Comment More infoAdvertise with us Next Article Tensorflow.js tf.sign() Function N nidhi1352singh Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads 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.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.neg() 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 .neg() function is used to calculate -1 * x i.e. input tensor and is done element wise. Syntax: Â tf.neg(x) 1 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.tan() 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 .tan() function is used to find the tangent of the stated tensor input and is done element wise. Syntax: tf.t 2 min read Like