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

Function TrainStream

browser.js:4877–4917  ·  view source on GitHub ↗
(opts)

Source from the content-addressed store, hash-verified

4875 _inherits(TrainStream, _Writable);
4876
4877 function TrainStream(opts) {
4878 var _ret;
4879
4880 _classCallCheck(this, TrainStream);
4881
4882 var _this = _possibleConstructorReturn(this, (TrainStream.__proto__ || Object.getPrototypeOf(TrainStream)).call(this, {
4883 objectMode: true
4884 }));
4885
4886 opts = opts || {};
4887
4888 // require the neuralNetwork
4889 if (!opts.neuralNetwork) {
4890 throw new Error('no neural network specified');
4891 }
4892
4893 _this.neuralNetwork = opts.neuralNetwork;
4894 _this.hiddenLayers = opts.neuralNetwork.hiddenLayers;
4895 _this.dataFormatDetermined = false;
4896
4897 _this.inputKeys = [];
4898 _this.outputKeys = []; // keeps track of keys seen
4899 _this.i = 0; // keep track of the for loop i variable that we got rid of
4900 _this.iterations = opts.iterations || 20000;
4901 _this.errorThresh = opts.errorThresh || 0.005;
4902 _this.log = opts.log ? typeof opts.log === 'function' ? opts.log : console.log : false;
4903 _this.logPeriod = opts.logPeriod || 10;
4904 _this.callback = opts.callback;
4905 _this.callbackPeriod = opts.callbackPeriod || 10;
4906 _this.floodCallback = opts.floodCallback;
4907 _this.doneTrainingCallback = opts.doneTrainingCallback;
4908
4909 _this.size = 0;
4910 _this.count = 0;
4911
4912 _this.sum = 0;
4913
4914 _this.on('finish', _this.finishStreamIteration.bind(_this));
4915
4916 return _ret = _this, _possibleConstructorReturn(_this, _ret);
4917 }
4918
4919 _createClass(TrainStream, [{
4920 key: 'endInputs',

Callers

nothing calls this directly

Calls 2

_classCallCheckFunction · 0.70

Tested by

no test coverage detected