MCPcopy
hub / github.com/tensorflow/tfjs / syncData

Method syncData

tfjs-layers/src/base_callbacks.ts:316–337  ·  view source on GitHub ↗

* Await the values of all losses and metrics.

()

Source from the content-addressed store, hash-verified

314 * Await the values of all losses and metrics.
315 */
316 async syncData() {
317 const promises: Array<Promise<Float32Array|Int32Array|Uint8Array>> = [];
318 const keys: string[] = [];
319 const indices: number[] = [];
320 for (const key in this.history) {
321 const valueArray = this.history[key];
322 for (let i = 0; i < valueArray.length; ++i) {
323 if (typeof valueArray[i] !== 'number') {
324 const valueScalar = valueArray[i] as Tensor;
325 promises.push(valueScalar.data());
326 keys.push(key);
327 indices.push(i);
328 }
329 }
330 }
331 const values = await Promise.all(promises);
332 for (let n = 0; n < values.length; ++n) {
333 const tensorToDispose = this.history[keys[n]][indices[n]] as Tensor;
334 tensorToDispose.dispose();
335 this.history[keys[n]][indices[n]] = values[n][0];
336 }
337 }
338}
339
340export interface CustomCallbackArgs {

Callers 2

fitLoopMethod · 0.80
fitDatasetFunction · 0.80

Calls 4

allMethod · 0.80
dataMethod · 0.65
pushMethod · 0.45
disposeMethod · 0.45

Tested by

no test coverage detected