Tensorflow.js tf.Tensor class .dataSync() 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. 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 .dataSync() method is used to synchronously download the values from the tf.Tensor.
Syntax:
dataSync()
Parameters:
Return Value: It returns DataTypeMap[NumericDataType]
Example 1:
Javascript
import * as tf from "@tensorflow/tfjs"
console.log(tf.tensor([1, 3, 5, 4, 2]).dataSync())
|
Output:
1, 3, 5, 4, 2
Example 2:
Javascript
import * as tf from "@tensorflow/tfjs"
const a= tf.tensor2d([[0, 1], [2, 3]])
console.log(a.dataSync())
|
Output:
0, 1, 2, 3
Reference: https://js.tensorflow.org/api/latest/#tf.Tensor.dataSync
Share your thoughts in the comments
Please Login to comment...