MCPcopy Create free account
hub / github.com/tensorflow/tfjs / constructor

Method constructor

tfjs-layers/src/base_callbacks.ts:375–401  ·  view source on GitHub ↗
(args: CustomCallbackArgs, yieldEvery?: YieldEveryOptions)

Source from the content-addressed store, hash-verified

373 public nextFrameFunc: Function;
374
375 constructor(args: CustomCallbackArgs, yieldEvery?: YieldEveryOptions) {
376 super();
377 this.nowFunc = args.nowFunc;
378 this.nextFrameFunc = args.nextFrameFunc || nextFrame;
379 this.yieldEvery = yieldEvery || 'auto';
380 if (this.yieldEvery === 'auto') {
381 this.yieldEvery = DEFAULT_YIELD_EVERY_MS;
382 }
383 if (this.yieldEvery === 'never' && args.onYield != null) {
384 throw new Error(
385 'yieldEvery is `never` but you provided an `onYield` callback. ' +
386 'Either change `yieldEvery` or remove the callback');
387 }
388 if (util.isNumber(this.yieldEvery)) {
389 // Decorate `maybeWait` so it will be called at most once every
390 // `yieldEvery` ms.
391 this.maybeWait = generic_utils.debounce(
392 this.maybeWait.bind(this), this.yieldEvery as number, this.nowFunc);
393 }
394 this.trainBegin = args.onTrainBegin;
395 this.trainEnd = args.onTrainEnd;
396 this.epochBegin = args.onEpochBegin;
397 this.epochEnd = args.onEpochEnd;
398 this.batchBegin = args.onBatchBegin;
399 this.batchEnd = args.onBatchEnd;
400 this.yield = args.onYield;
401 }
402
403 async maybeWait(epoch: number, batch: number, logs: UnresolvedLogs) {
404 const ps: Array<void|Promise<void>> = [];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected