Tensorflow.js tf.mod() Function Last Updated : 25 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.mod() function returns element-wise remainder of division. Operation: floor(x / y) * y + mod(x, y) = x. Note: It supports broadcasting. Syntax: tf.mod(x, y). Parameters: This function accepts three parameters which are illustrated below: x: It is a Tensor.y: It is a Tensor. It must be of the same type as x. Return Value: A Tensor. Has the same type as x. Example 1: We also expose tf.mod() which has the same signature as this operation and asserts that a and b have the same shape (does not broadcast). JavaScript // Importting the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Creating the tensor const x = tf.tensor([9, 12, 3, 20, 7]); const y = tf.tensor([2, 2, 9, 4, 2]); tf.mod(x,y).print(); Output: Tensor [1, 0, 3, 0, 1] Example 2: The simplest broadcasting example when an array and a scalar value are combined in an operation: JavaScript // Importing the tensorflow library import * as tf from "@tensorflow/tfjs" // Broadcast a mod b. const x = tf.tensor([2, 4, 5, 8]); const y = tf.scalar(5); x.mod(y).print(); Output: Tensor [2, 4, 0, 3] Reference: https://js.tensorflow.org/api/latest/#mod Comment More infoAdvertise with us Next Article Tensorflow.js tf.mod() Function R rathikhushbu112 Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.prod() 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.prod() function is used to calculate product of the elements of a specified Tensor across its dimension. It reduces the given i 2 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 Tensorflow.js tf.pow() 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.pow() function is used to compute the power of one specified tensor to another. It supports broadcasting. Syntax: tf.power(base 1 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 Tensorflow.js tf.max() 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.max() function is used to calculate the maximum value from the specified Tensor across its dimension. It reduces the given inpu 2 min read Tensorflow.js tf.log() 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 .log() function is used to find the natural logarithm of the stated tensor input i.e. ln(x) and is done eleme 1 min read Tensorflow.js tf.round() 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 .round() function is used to find the round value of the stated tensor input, and it is done element wise. Mo 2 min read Tensorflow.js tf.min() 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.min() function is used to calculate the minimum value from the specified Tensor across its dimension. It reduces the given inpu 2 min read Tensorflow.js tf.norm() 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.norm() function is used compute the norm of matrices, vectors, and scalar. This function can also compute several other vector 2 min read Tensorflow.js tf.ones() Function Tensorflow.js is an open-source library for running machine learning models and deep learning neural networks in the browser or node environment. The tf.ones() function is used to create a new tensor where all elements are set to 1. Syntax: tf.ones(shape, dtype, name) Parameters: shape: It takes the 2 min read Like