Tensorflow tf.add() Function Last Updated : 07 Jun, 2022 Comments Improve Suggest changes Like Article Like Report The tf.add() function returns the addition of two tf.Tensor objects element wise. The tf.Tensor object represents the multidimensional array of numbers. Syntax: tf.add( a, b ) Parameters: a: It contains the first tf.Tensor object that is to be added. The value of this parameter can be tf.TensorTypedArray|Array.b: It contains the second tf.Tensor object that is to be added into the first tf.Tensor object. The value of this parameter can be (tf.Tensor|TypedArray|Array). The type of this parameter is same as type of a. Return Value: This function returns the tf.Tensor object. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Declare the Tensor array const arr1 = tf.tensor1d([10, 20, 30, 40, 50]); const arr2 = tf.tensor1d([5, 10, 15, 20, 25]); // Use add() function to add // two Tensor objects arr1.add(arr2).print(); Output: Tensor [15, 30, 45, 60, 75] Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Declare the Tensor array const arr1 = tf.tensor1d([30, 40, 50]); const arr2 = tf.tensor1d([5, 10, 15, 20, 25]); // Use add() function to add // two Tensor objects arr1.add(arr2).print(); Output: An error occurred on line: 7 Operands could not be broadcast together with shapes 3 and 5. Example 3: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Declare the Tensor array const arr = tf.tensor1d([5, 10, 15, 20, 25]); // Declare a number const num = tf.scalar(30); // Use add() function to add // Tensor object and a number arr.add(num).print(); Output: Tensor [35, 40, 45, 50, 55] Reference: https://js.tensorflow.org/api/latest/#add Comment More infoAdvertise with us Next Article Tensorflow tf.add() Function A ashokjaiswal Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.addN() 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.addN() function is used to add a specified list of Tensors element-wise. Each Tensor should be of the same shape and data type. 1 min read Tensorflow.js tf.dot() 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.dot() function is used to compute the dot product of two given matrices or vectors, t1 and t2. Syntax:Â tf.dot(t1, t2); Paramet 1 min read Tensorflow.js tf.atan() 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 .atan() function is used to find the atan of the stated tensor input and is done element wise. Syntax : Â tf. 2 min read Tensorflow tf.mul() Function The tf.mul() function returns the multiplication of two tf.Tensor objects element wise. The tf.Tensor object represents the multidimensional array of numbers. Syntax: tf.mul( a, b ) Parameters: a: It contains the first tf.Tensor object that multiplied by second tf.Tensor object element-wise. The val 2 min read Tensorflow tf.sub() Function The tf.sub() function returns the subtraction of two tf.Tensor objects element wise. The tf.Tensor object represents the multidimensional array of numbers. Syntax: tf.sub( a, b ) Parameters: a: It contains the first tf.Tensor object. The value of this parameter can be tf.TensorTypedArray|Array.b: It 2 min read Tensorflow.js tf.layers.add() 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 Node.js. The tf.lay 2 min read Tensorflow.js tf.expandDims() 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 .expandDims() function is used to find tf.Tensor object whose rank is expanded with the help of tensor's shape by i 2 min read Tensorflow.js tf.atan2() 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 .atan2() function is used to find the arctangent of the stated tensor inputs and is done element wise. Moreov 2 min read Tensorflow.js tf.elu() 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 .elu() function is used to find the exponential linear of the stated tensor input and is done elements wise. 2 min read Tensorflow.js tf.exp() 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 .exp() function is used to find the exponential value i.e, (e^x) of the stated tensor input, and it is done e 2 min read Like