* Collect all elements of this dataset into an array. * * Obviously this will succeed only for small datasets that fit in memory. * Useful for testing and generally should be avoided if possible. * * ```js * const a = tf.data.array([1, 2, 3, 4, 5, 6]); * console.log(await a.toAr
()
| 506 | * @doc {heading: 'Data', subheading: 'Classes'} |
| 507 | */ |
| 508 | async toArray() { |
| 509 | if (this.size === Infinity) { |
| 510 | throw new Error('Can not convert infinite data stream to array.'); |
| 511 | } |
| 512 | return (await this.iterator()).toArray(); |
| 513 | } |
| 514 | |
| 515 | /** |
| 516 | * Collect all elements of this dataset into an array with prefetching 100 |