* Creates a `Dataset` that skips `count` initial elements from this dataset. * * ```js * const a = tf.data.array([1, 2, 3, 4, 5, 6]).skip(3); * await a.forEachAsync(e => console.log(e)); * ``` * * @param count: The number of elements of this dataset that should be skipped *
(count: number)
| 382 | * @doc {heading: 'Data', subheading: 'Classes'} |
| 383 | */ |
| 384 | skip(count: number): Dataset<T> { |
| 385 | const base = this; |
| 386 | let size; |
| 387 | if (this.size != null && count >= 0 && this.size >= count) { |
| 388 | // If the size of this dataset is greater than count, the new dataset's |
| 389 | // size is current size minus skipped size.This also covers the case that |
| 390 | // current size is infinity. |
| 391 | size = this.size - count; |
| 392 | } else if ( |
| 393 | this.size != null && |
| 394 | (this.size < count || count === undefined || count < 0)) { |
| 395 | // If the size of this dataset is smaller than count, or count is |
| 396 | // undefined or negative, skips the entire dataset and the new size is 0. |
| 397 | size = 0; |
| 398 | } else { |
| 399 | // If the size of this dataset is null, the new dataset's size is null. |
| 400 | size = null; |
| 401 | } |
| 402 | return datasetFromIteratorFn( |
| 403 | async () => (await base.iterator()).skip(count), size); |
| 404 | } |
| 405 | |
| 406 | // TODO(soergel): deep sharded shuffle, where supported |
| 407 |
nothing calls this directly
no test coverage detected
searching dependent graphs…