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

Method _validateTrainingOptions

src/neural-network.js:47–64  ·  view source on GitHub ↗

* * @param options * @private

(options)

Source from the content-addressed store, hash-verified

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);

Callers 3

browser.min.jsFile · 0.80
browser.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected