* * @param options * @private
(options)
| 45 | * @private |
| 46 | */ |
| 47 | static _validateTrainingOptions(options) { |
| 48 | const validations = { |
| 49 | iterations: (val) => { return typeof val === 'number' && val > 0; }, |
| 50 | errorThresh: (val) => { return typeof val === 'number' && val > 0 && val < 1; }, |
| 51 | log: (val) => { return typeof val === 'function' || typeof val === 'boolean'; }, |
| 52 | logPeriod: (val) => { return typeof val === 'number' && val > 0; }, |
| 53 | learningRate: (val) => { return typeof val === 'number' && val > 0 && val < 1; }, |
| 54 | momentum: (val) => { return typeof val === 'number' && val > 0 && val < 1; }, |
| 55 | callback: (val) => { return typeof val === 'function' || val === null }, |
| 56 | callbackPeriod: (val) => { return typeof val === 'number' && val > 0; }, |
| 57 | timeout: (val) => { return typeof val === 'number' && val > 0 } |
| 58 | }; |
| 59 | Object.keys(NeuralNetwork.trainDefaults).forEach(key => { |
| 60 | if (validations.hasOwnProperty(key) && !validations[key](options[key])) { |
| 61 | throw new Error(`[${key}, ${options[key]}] is out of normal training range, your network will probably not train.`); |
| 62 | } |
| 63 | }); |
| 64 | } |
| 65 | |
| 66 | constructor(options = {}) { |
| 67 | Object.assign(this, this.constructor.defaults, options); |
no outgoing calls
no test coverage detected