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.
Syntax:
tf.addN (tensors)
Parameters: This function accepts a parameter which is illustrated below:
- tensors: The array/list of specified tensors with the same shape and data type.
Return Value: It returns a Tensor of added elements.
Example 1:
Javascript
import * as tf from "@tensorflow/tfjs"
const a = tf.tensor1d([0, 1, 2]);
const b = tf.tensor1d([3, 4, 5]);
tf.addN([a, b]).print();
|
Output:
Tensor
[3, 5, 7]
Example 2:
Javascript
import * as tf from "@tensorflow/tfjs"
tf.addN([[12, 5, 6], [3, 2, 5], [2, 7, 9]]).print();
|
Output:
Tensor
[17, 14, 20]
Reference: https://js.tensorflow.org/api/latest/#addN
Last Updated :
12 May, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...