Wednesday, July 3, 2024
HomeLanguagesJavascriptTensorflow.js tf.Tensor class .data() Method

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.Tensor class .data() method is used to asynchronously download the values from the tf.Tensor.

Syntax:

data()

Parameters: It does not accept any parameter.

Return Value: It returns Promise <DataTypeMap[NumericDataType]>.

Example 1:

Javascript




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


Output:

Example 2: Creating a 2d tensor

Javascript




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


Output:

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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Nicole Veronica Rubhabha
Nicole Veronica Rubhabha
A highly competent and organized individual DotNet developer with a track record of architecting and developing web client-server applications. Recognized as a personable, dedicated performer who demonstrates innovation, communication, and teamwork to ensure quality and timely project completion. Expertise in C#, ASP.Net, MVC, LINQ, EF 6, Web Services, SQL Server, MySql, Web development,
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments