MCPcopy Create free account
hub / github.com/BrainJS/brain.js / _write

Method _write

src/train-stream.js:61–83  ·  view source on GitHub ↗

* _write expects data to be in the form of a datum. ie. {input: {a: 1 b: 0}, output: {z: 0}} * @param chunk * @param enc * @param next * @returns {*} * @private

(chunk, enc, next)

Source from the content-addressed store, hash-verified

59 * @private
60 */
61 _write(chunk, enc, next) {
62 if (!chunk) {
63 // check for the end of one iteration of the stream
64 this.emit('finish');
65 return next();
66 }
67
68 if (!this.dataFormatDetermined) {
69 this.size++;
70 this.inputKeys = uniques(this.inputKeys.slice(0).concat(Object.keys(chunk.input)));
71 this.outputKeys = uniques(this.outputKeys.slice(0).concat(Object.keys(chunk.output)));
72 this.firstDatum = this.firstDatum || chunk;
73 return next();
74 }
75
76 this.count++;
77
78 let data = this.neuralNetwork._formatData(chunk);
79 this.trainDatum(data[0]);
80
81 // tell the Readable Stream that we are ready for more data
82 next();
83 }
84
85 /**
86 *

Callers 2

doWriteFunction · 0.80
doWriteFunction · 0.80

Calls 3

trainDatumMethod · 0.95
_formatDataMethod · 0.80
uniquesFunction · 0.70

Tested by

no test coverage detected