- generator<T>(generator): Dataset<T>
Parameters
generator: (() => Iterator<T, any, undefined> | Promise<Iterator<T, any, undefined>>)
- (): Iterator<T, any, undefined> | Promise<Iterator<T, any, undefined>>
Returns Iterator<T, any, undefined> | Promise<Iterator<T, any, undefined>>
Create a
Dataset
that produces each element from provided JavaScript generator, which is a function* (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators#Generator_functions), or a function that returns an iterator (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators#Generator_functions).The returned iterator should have
.next()
function that returns element in format of{value: TensorContainer, done:boolean}
.Example of creating a dataset from an iterator factory:
Example of creating a dataset from a generator: