VOOZH about

URL: https://www.geeksforgeeks.org/javascript/tensorflow-js-tf-tensorbuffer-class-totensor-method/

⇱ Tensorflow.js tf.TensorBuffer Class .toTensor() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Tensorflow.js tf.TensorBuffer Class .toTensor() Method

Last Updated : 22 Apr, 2022

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.

Syntax:

toTensor ()

Parameters: This function does not accept any parameters.

Return Value: It returns the created immutable Tensor object.

Example 1:

Output:

Tensor
 [[5 , 0],
 [10, 0]]

Example 2:

Output:

Tensor
 [[5 , 10, 0 ],
 [15, 20, 0 ],
 [25, 30, 35]]

Reference: https://js.tensorflow.org/api/latest/#tf.TensorBuffer.toTensor

Comment