Tensorflow.js tf.scatterND() Function Last Updated : 25 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 .scatterND() function is used to form a different tensor by utilizing scattered updates to the individual slices or values inside a zero tensor of the stated shape tensor in accordance with the stated indices. Moreover, this function is negation of the tf.gatherND() function that takes slices or values from a stated tensor. Syntax: tf.scatterND(indices, updates, shape) Parameters: indices: It is the stated tensor that holds the indices towards the output tensor, and it can be of type tf.Tensor, TypedArray, or Array.updates: It is the stated tensor that holds the values for the indices, and it can be of type tf.Tensor, TypedArray, or Array.shape: It is the stated shape of the output tensor and is of type number[]. Return Value: It returns tf.Tensor object. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Defining indices, updates and shape const ind = tf.tensor2d([6, 5, 2], [3, 1], 'int32'); const updat = tf.tensor1d([1, 2, 3]); const shp = [6]; // Calling tf.scatterND() method and // Printing output tf.scatterND(ind, updat, shp).print(); Output: Tensor [0, 0, 3, 0, 0, 2] Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Calling tf.scatterND() method and // Printing output tf.scatterND(tf.tensor2d([5.4, 2.4], [2, 1], 'int32'), tf.tensor1d([1.8, 4.2]), [4]).print(); Output: Tensor [0, 0, 4.1999998, 0] Reference: https://js.tensorflow.org/api/latest/#scatterND Comment More infoAdvertise with us Next Article Tensorflow.js tf.scatterND() Function N nidhi1352singh Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.scalar() 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 .scalar() function is used to create a scalar type of tensor means. A scalar is a zero-dimension array and is also called a rank-0 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.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.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 Tensorflow.js tf.tensor2d() 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 .tensor2d() function is used to create a new 2-dimensional tensor with the parameter namely value, shape, and datatype. Syntax: tf 3 min read Like