* * @returns {Object}
()
| 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()); |
no test coverage detected