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

Method _prepTraining

src/neural-network-gpu.js:349–381  ·  view source on GitHub ↗

* * @param data * @param options * @protected * @return { data, status, endTime }

(data, options)

Source from the content-addressed store, hash-verified

347 * @return { data, status, endTime }
348 */
349 _prepTraining(data, options) {
350 this._updateTrainingOptions(options);
351 data = this._formatData(data);
352 const endTime = Date.now() + this.trainOpts.timeout;
353
354 const status = {
355 error: 1,
356 iterations: 0
357 };
358
359 this._verifyIsInitialized(data);
360
361 const texturizeOutputData = this.gpu.createKernel(function(value) {
362 return value[this.thread.x];
363 }, {
364 output: [data[0].output.length],
365 outputToTexture: true,
366 hardcodeConstants: true,
367 outputImmutable: true
368 });
369
370 return {
371 data: data.map((set) => {
372 return {
373 size: set.size,
374 input: this._texturizeInputData(set.input),
375 output: texturizeOutputData(set.output)
376 }
377 }),
378 status,
379 endTime
380 };
381 }
382
383 toFunction() {
384 throw new Error('not implemented on NeuralNetworkGPU');

Callers

nothing calls this directly

Calls 3

_verifyIsInitializedMethod · 0.95
_formatDataMethod · 0.80

Tested by

no test coverage detected