Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Tensorflow.js tf.Tensor class .buffer() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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.Tensor class.buffer() method is used to return a promise of tf.TensorBuffer that holds the underlying data.

Syntax:

buffer()

Parameters: It does not accept any parameters.

Return Value: It returns Promise <tf.TensorBuffer>.

Example 1: Creating a 2d tensor.

Javascript




const a= tf.tensor2d([[0, 1], [2, 3]])
  
console.log(a.buffer())


Output:

Example 2:

Javascript




const a= tf.tensor([1, 3, 5, 4, 2])
  
console.log(a.buffer())


Output:

Reference: https://js.tensorflow.org/api/latest/#tf.Tensor.buffer

My Personal Notes arrow_drop_up
Last Updated : 22 Apr, 2022
Like Article
Save Article
Similar Reads
Related Tutorials