* Repeats this dataset `count` times. * * NOTE: If this dataset is a function of global state (e.g. a random number * generator), then different repetitions may produce different elements. * * ```js * const a = tf.data.array([1, 2, 3]).repeat(3); * await a.forEachAsync(e => cons
(count?: number)
| 339 | * @doc {heading: 'Data', subheading: 'Classes'} |
| 340 | */ |
| 341 | repeat(count?: number): Dataset<T> { |
| 342 | const base = this; |
| 343 | let size; |
| 344 | if (this.size != null && count > 0) { |
| 345 | // If this dataset has size and count is positive, new size is current |
| 346 | // size multiply count. This also covers the case that current size is |
| 347 | // infinity. |
| 348 | size = this.size * count; |
| 349 | } else if (count === 0) { |
| 350 | // If count is 0, new size is 0. |
| 351 | size = 0; |
| 352 | } else if (this.size != null && (count === undefined || count < 0)) { |
| 353 | // If this dataset has size and count is undefined or negative, the |
| 354 | // dataset will be repeated indefinitely and new size is infinity. |
| 355 | size = Infinity; |
| 356 | } else { |
| 357 | // If the size of this dataset is null, the new dataset's size is null. |
| 358 | size = null; |
| 359 | } |
| 360 | return datasetFromIteratorFn(async () => { |
| 361 | const iteratorIterator = iteratorFromFunction( |
| 362 | async () => ({value: await base.iterator(), done: false})); |
| 363 | return iteratorFromConcatenated(iteratorIterator.take(count)); |
| 364 | }, size); |
| 365 | } |
| 366 | |
| 367 | /** |
| 368 | * Creates a `Dataset` that skips `count` initial elements from this dataset. |
nothing calls this directly
no test coverage detected
searching dependent graphs…