Tensorflow.js tf.data.Dataset class .take() 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 .take() method is used to form a dataset with maximum count foremost items out of the stated dataset. Syntax: take(count) Parameters: count: It is the number of elements present in the stated dataset that is to be utilized to create the different dataset. Moreover, in case the count is not defined or else negative or is higher than the dimension of the stated dataset then the newly created dataset will hold each item of the given dataset. 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 // numbers and calling take() method const res = tf.data.array([11, 12, 31, 43, 15, 64]).take(4); // Calling forEachAsync() method and // Printing output await res.forEachAsync(op => console.log(op)); Output: 11 12 31 43 Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Calling forEachAsync(), take() method // and printing output await tf.data.array([31.1, 81.2, 5.1, 0, NaN, 'a']). take(10.7).forEachAsync(op => console.log(op)); Output: 31.1 81.2 5.1 0 NaN a Reference: https://js.tensorflow.org/api/latest/#tf.data.Dataset.take Comment More infoAdvertise with us Next Article Tensorflow.js tf.data.Dataset class .take() Method nidhi1352singh Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads 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 .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 .toArray() 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 .toArray() method is used to accumulate each elements of the stated dataset within an array. Syntax: Â toArray() Pa 1 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.skip() Method Tensorflow.js is an open-source library that is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The tf.data.Dataset.skip() method is used to create a dataset that skips count initial elements from this dataset 1 min read Like