concept generator function in category deep learning

appears as: generator function, generator functions
Deep Learning with JavaScript: Neural networks in TensorFlow.js

This is an excerpt from Manning's book Deep Learning with JavaScript: Neural networks in TensorFlow.js.

Creating a tf.data.Dataset from a generator function

The third and most flexible way to create a tf.data.Dataset is to build one from a generator function. This is done using the tf.data.generator() method. tf.data.generator() takes a JavaScript generator function (or function*)[5] as its argument. If you are not familiar with generator functions, which are relatively new to JavaScript, you may wish to take a moment to read their documentation. The purpose of a generator function is to “yield” a sequence of values as they are needed, either forever or until the sequence is exhausted. The values that are yielded from the generator function flow through to become the values of the dataset. A very simple generator function might, for instance, yield random numbers or extract snapshots of data from a piece of attached hardware. A sophisticated generator may be integrated with a video game, yielding screen captures, scores, and control input-output. In the following listing, the very simple generator function yields samples of dice rolls.