MCPcopy
hub / github.com/BrainJS/brain.js / trainAsync

Method trainAsync

src/neural-network.js:467–483  ·  view source on GitHub ↗

* * @param data * @param options * @returns {Promise} * @resolves {{error: number, iterations: number}} * @rejects {{trainError: string, status: {error: number, iterations: number}}

(data, options = {})

Source from the content-addressed store, hash-verified

465 * @rejects {{trainError: string, status: {error: number, iterations: number}}
466 */
467 trainAsync(data, options = {}) {
468 let status, endTime;
469 ({ data, status, endTime } = this._prepTraining(data, options));
470
471 return new Promise((resolve, reject) => {
472 try {
473 const thawedTrain = new Thaw(new Array(this.trainOpts.iterations), {
474 delay: true,
475 each: () => this._trainingTick(data, status, endTime) || thawedTrain.stop(),
476 done: () => resolve(status)
477 });
478 thawedTrain.tick();
479 } catch (trainError) {
480 reject({trainError, status});
481 }
482 });
483 }
484
485 /**
486 *

Callers 3

trainWithLogAsyncFunction · 0.95
testBitwiseAsyncFunction · 0.95
trainopts.jsFile · 0.80

Calls 2

_prepTrainingMethod · 0.95
_trainingTickMethod · 0.95

Tested by

no test coverage detected