Skip to content

Commit

Permalink
Removed goodies
Browse files Browse the repository at this point in the history
`trainTimeMs` is gone and will be in a new pr

`log` doesn't accept functions but will be in a new pr

The tests pass (ugly but they pass lol)

https://memegenerator.net/img/instances/75216624.jpg

good thing no one actually looks at commit messages amirite?
  • Loading branch information
freddyC committed Jan 23, 2018
1 parent 4782432 commit b4cd266
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/neural-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export default class NeuralNetwork {
logPeriod: 10,
learningRate: 0.3,
callback: null,
callbackPeriod: 10,
trainTimeMs: -Infinity
callbackPeriod: 10
};
}

Expand Down Expand Up @@ -250,13 +249,11 @@ export default class NeuralNetwork {
/**
*
* @param log
* if true passed in console.log is used
* if a method is passed in method is used
* if false passed in nothing is logged
* @returns error
*/
_setLogMethod(log) {
if (typeof log === 'function') return log;
if (log) return console.log;
return false;
}
Expand Down Expand Up @@ -304,7 +301,6 @@ export default class NeuralNetwork {
data = this.formatData(data);
options.log = this._setLogMethod(options.log);
options.learningRate = _options.learningRate || this.learningRate || options.learningRate;
let endTime = Date.now() + options.trainTimeMs;
var status = {
error: 1,
iterations: 0
Expand All @@ -314,9 +310,11 @@ export default class NeuralNetwork {
let sizes = this._getSizesFromData(data);
this.initialize(sizes);
}
while ( status.iterations < options.iterations && status.error > options.errorThresh && Date.now() > endTime ) {

while ( status.iterations < options.iterations && status.error > options.errorThresh) {
this._checkTrainingTick(data, status, options);
}

return status;
}

Expand Down Expand Up @@ -351,7 +349,7 @@ export default class NeuralNetwork {
each: () => {
this._checkTrainingTick(data, status, options);

if (status.error < options.errorThresh || Date.now() < endTime) {
if (status.error < options.errorThresh) {
thaw.stop();
}
},
Expand Down
13 changes: 13 additions & 0 deletions test/base/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,22 @@ describe('async neural network options', () => {

describe('log', () => {
let logCalled = false;
let oldLog;

beforeEach(() => { logCalled = false; });

before(() => {
oldLog = console.log;
console.log = () => {
oldLog(arguments);
logCalled = true;
}
})

after(() => {
console.log = oldLog;
})

function logFunction(str) {
logCalled = true;
}
Expand Down

0 comments on commit b4cd266

Please sign in to comment.