MCPcopy Index your code
hub / github.com/tensorflow/tfjs / mapAsync

Function mapAsync

tfjs-data/src/dataset.ts:295–301  ·  view source on GitHub ↗

* Maps this dataset through an async 1-to-1 transform. * * ```js * const a = * tf.data.array([1, 2, 3]).mapAsync(x => new Promise(function(resolve){ * setTimeout(() => { * resolve(x * x); * }, Math.random()*1000 + 500); * })); * console.log(await a.toArray());

(transform: (value: T) => Promise<O>)

Source from the content-addressed store, hash-verified

293 * @doc {heading: 'Data', subheading: 'Classes'}
294 */
295 mapAsync<O extends tf.TensorContainer>(transform: (value: T) => Promise<O>):
296 Dataset<O> {
297 const base = this;
298 return datasetFromIteratorFn(async () => {
299 return (await base.iterator()).mapAsync(transform);
300 }, this.size);
301 }
302
303 /**
304 * Creates a `Dataset` that prefetches elements from this dataset.

Callers

nothing calls this directly

Calls 2

datasetFromIteratorFnFunction · 0.85
iteratorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…