Tensorflow.js tf.data.array() Method Last Updated : 04 Jun, 2021 Comments Improve Suggest changes 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 .data.array() method is used to form a dataset based on an array made from elements. Syntax : tf.data.array(items) Parameters: items: It is the stated array made from elements that is to be parsed in a dataset like items, and it can be of type tf.void, number, string, TypedArray, tf.Tensor, tf.Tensor[], or {[key: string]:tf.Tensor, number, or string}[]. Return Value: It returns tf.data.Dataset. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Defining dataset formed of an array // of objects and calling data.array() const res = tf.data.array([ {'element': 5}, {'element': 6}, {'element': 7} ]); // Calling forEachAsync() method and // Printing output await res.forEachAsync(op => console.log(op)); Output: { "element": 5 } { "element": 6 } { "element": 7 } Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Defining dataset formed of an array // of numbers and calling data.array() const res = tf.data.array([4.6, 7.9, 9.6, 2.6, 8.9]); // Calling forEachAsync() method and // Printing output await res.forEachAsync(op => console.log(op)); Output: 4.6 7.9 9.6 2.6 8.9 Reference: https://js.tensorflow.org/api/latest/#data.array Comment More infoAdvertise with us Next Article Tensorflow.js tf.data.array() Method N nidhi1352singh Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.Tensor class .array() 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 .ar 1 min read 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. 1 min read 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.T 1 min read 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.Tensor class .dataSync() 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