Friday, October 24, 2025
HomeLanguagesJavascriptTensorflow.js tf.Tensor class .arraySync() Method

Tensorflow.js tf.Tensor class .arraySync() 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 .arraySync() method is used to return the tensor data as a nested array.

Syntax:

arraySync()

Parameters: It does not accept any parameters.

Return Value: It returns number[].

Example 1: Creating a 2d tensor.

Javascript




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


Output:

[[0, 1], [2, 3]]

Example 2:

Javascript




console.log(tf.tensor([1, 3, 5, 4, 2]).arraySync())


Output:

[1, 3, 5, 4, 2]

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

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS