Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Tensorflow.js tf.data.Dataset.repeat() Function

  • Last Updated : 24 May, 2021

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.data.Dataset.repeat() function is used to repeat the dataset count time

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

Syntax:

repeat (count?)

Parameters



  • count: An integer, representing the number of times the dataset should be repeated.

Return Value: It returns tf.data.Dataset.

Example 1:

Javascript




const a = tf.data.array([1, 2, 3]).repeat(3);
  
await a.forEachAsync(e => console.log(e)),

Output:

​1
2
3
1
2
3
1
2
3

Example 2:

Javascript




const a = tf.data.array([2, 4, 6]).repeat(5);
  
await a.forEachAsync(e => console.log(e*2));

Output:

4
8
12
4
8
12
4
8
12
4
8
12
4
8
12

Reference: https://js.tensorflow.org/api/latest/#tf.data.Dataset.repeat

My Personal Notes arrow_drop_up
Recommended Articles
Page :