Tensorflow.js tf.data.Dataset class .toArray() Method Last Updated : 22 Apr, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .toArray() method is used to accumulate each elements of the stated dataset within an array. Syntax: toArray() Parameters: This method does not hold any parameter. Return Value: It returns Promise( T[] ). Note: This method applies for limited datasets only i.e. the one that fits in the memory.It is utilized for testing purpose and should be mostly abstained when conceivable. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Defining dataset formed of an array // of numbers const res = tf.data.array([11, 12, 31, 43, 15, 64]); // Calling toArray() method and // Printing output console.log(await res.toArray()); Output: 11, 12, 31, 43, 15, 64 Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Calling toArray() method and // Printing output console.log(await tf.data.array([5.7, -16, .31, 0, null, NaN]).toArray()); Output: 5.7, -16, 0.31, 0, , NaN Reference: https://js.tensorflow.org/api/latest/#tf.data.Dataset.toArray Comment More infoAdvertise with us Next Article Tensorflow.js tf.data.Dataset class.mapAsync() Method N nidhi1352singh Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js TensorFlow.js-Classes TensorFlow.js-Data +1 More Similar Reads Tensorflow.js tf.data.Dataset class .take() Method Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .take() method is used to form a dataset with maximum count foremost items out of the stated dataset. Syntax: take( 2 min read Tensorflow.js tf.data.Dataset class .batch() 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. 2 min read Tensorflow.js tf.data.Dataset class.mapAsync() Method Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .mapAsync() method is used to map the stated dataset over an asynchronous one to one conversion. Syntax: mapAsync(t 2 min read Tensorflow.js tf.data.Dataset class .prefetch() 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. The tf.data.Dataset class .prefetch() function is used to produce a dataset that prefetches the specified elements from this given dat 2 min read Tensorflow.js tf.data.Dataset Class 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. Tensorflow.js tf.data.Dataset class represents the large collection of data. Data can be an array, a map, or primitive, or can be any 2 min read Tensorflow.js tf.data.Dataset class .forEachAsync() 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. 1 min read Like