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

Method toJSON

src/recurrent/rnn.js:431–458  ·  view source on GitHub ↗

* * @returns {Object}

()

Source from the content-addressed store, hash-verified

429 * @returns {Object}
430 */
431 toJSON() {
432 const defaults = this.constructor.defaults;
433 if (!this.model) {
434 this.initialize();
435 }
436 let model = this.model;
437 let options = {};
438 for (let p in defaults) {
439 if (defaults.hasOwnProperty(p)) {
440 options[p] = this[p];
441 }
442 }
443
444 return {
445 type: this.constructor.name,
446 options: options,
447 input: model.input.toJSON(),
448 hiddenLayers: model.hiddenLayers.map((hiddenLayer) => {
449 let layers = {};
450 for (let p in hiddenLayer) {
451 layers[p] = hiddenLayer[p].toJSON();
452 }
453 return layers;
454 }),
455 outputConnector: this.model.outputConnector.toJSON(),
456 output: this.model.output.toJSON()
457 };
458 }
459
460 toJSONString() {
461 return JSON.stringify(this.toJSON());

Callers 11

toJSONStringMethod · 0.95
toFunctionMethod · 0.95
browser.min.jsFile · 0.45
browser.jsFile · 0.45
lstm.jsFile · 0.45
gru.jsFile · 0.45
rnn.jsFile · 0.45
options.jsFile · 0.45
json.jsFile · 0.45
toFunctionMethod · 0.45

Calls 1

initializeMethod · 0.95

Tested by

no test coverage detected