Tensorflow.js tf.TensorBuffer class .get() Method Last Updated : 22 Apr, 2022 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.TensorBuffer class .get() method is used to return the value in the specified buffer for the given location. Syntax: get (...locations) Parameters: This method accepts single parameter which is illustrated below: locations: The specified location indices. Return Value: It returns the value at the specified location indices. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Creating a buffer of 2*2 dimensions const buffer = tf.buffer([2, 2]); // Setting values at particular indices. buffer.set(5, 0, 0); buffer.set(10, 1, 0); // Getting the values for the // specified indices with the // help of .get() function console.log(buffer.get(0, 0)); console.log(buffer.get(1, 0)); Output: 5 10 Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Creating a buffer of 3*3 dimensions const buffer = tf.buffer([3, 3]); // Setting values at particular indices. buffer.set(5, 0, 0); buffer.set(10, 0, 1); buffer.set(15, 1, 0); buffer.set(20, 1, 1); buffer.set(25, 2, 0); buffer.set(30, 2, 1); buffer.set(35, 2, 2); // Getting the values for the // specified indices with // the help of .get() functions console.log(buffer.get(0, 0)); console.log(buffer.get(0, 1)); console.log(buffer.get(1, 0)); console.log(buffer.get(2, 0)); console.log(buffer.get(2, 1)); console.log(buffer.get(2, 2)); Output: 5 10 15 25 30 35 Reference: https://js.tensorflow.org/api/latest/#tf.TensorBuffer.get Comment More infoAdvertise with us Next Article Tensorflow.js tf.TensorBuffer class .get() Method K Kanchan_Ray Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js TensorFlow.js-Classes TensorFlow.js-Tensor +1 More Similar Reads Tensorflow.js tf.TensorBuffer Class .set() Method 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.TensorBuffer class .set() function is used to set a given value in the buffer at a specified location. Syntax: set (value, ...l 2 min read Tensorflow.js tf.TensorBuffer Class .toTensor() Method 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.TensorBuffer class .toTensor() function is used to create an immutable Tensor object from the specified buffer and its values. 2 min read Tensorflow.js tf.Tensor class .data() Method 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. 1 min read Tensorflow.js tf.TensorBuffer Class 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. This TensorBuffer class mutable object is similar to tf.Tensor which permits users to set values at the specified locations before con 2 min read Tensorflow.js tf.Tensor class .clone() Method Tensorflow.js is an open-source library for creating machine learning models in Javascript that allows users to run the models directly in the browser. The tf.clone() is a function defined in the class tf.Tensor. It's used to create a replica of a tensor. Syntax : tf.clone( values ) Parameters: valu 1 min read Like