Skip to content

Commit

Permalink
fix legacy to support when no trainOpts are sent in, with test
Browse files Browse the repository at this point in the history
fix some semicolons and spaces
fix some jsdocs
bump version number
  • Loading branch information
robertleeplummerjr committed Mar 4, 2018
1 parent e3cbe93 commit 4d94d16
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 87 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
"node_modules",
"test"
],
"version": "1.0.5"
"version": "1.1.1"
}
75 changes: 23 additions & 52 deletions browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* license: MIT (http://opensource.org/licenses/MIT)
* author: Heather Arthur <[email protected]>
* homepage: https://github.com/brainjs/brain.js#readme
* version: 1.1.0
* version: 1.1.1
*
* acorn:
* license: MIT (http://opensource.org/licenses/MIT)
Expand Down Expand Up @@ -903,7 +903,6 @@ var NeuralNetwork = function () {
/**
*
* @param options
* @param boolean
* @private
*/
value: function _validateTrainingOptions(options) {
Expand Down Expand Up @@ -1042,7 +1041,7 @@ var NeuralNetwork = function () {

/**
*
* @param supported input: ['sigmoid', 'relu', 'leaky-relu', 'tanh']
* @param activation supported inputs: 'sigmoid', 'relu', 'leaky-relu', 'tanh'
*/

}, {
Expand Down Expand Up @@ -1220,12 +1219,12 @@ var NeuralNetwork = function () {

/**
*
* @param options
* @param opts
* Supports all `trainDefaults` properties
* also supports:
* learningRate: (number),
* momentum: (number),
* activation: ['sigmoid', 'relu', 'leaky-relu', 'tanh']
* activation: 'sigmoid', 'relu', 'leaky-relu', 'tanh'
*/

}, {
Expand Down Expand Up @@ -1282,8 +1281,7 @@ var NeuralNetwork = function () {
/**
*
* @param data
* @param learning Rate
* @returns error
* @returns number
*/

}, {
Expand All @@ -1298,8 +1296,9 @@ var NeuralNetwork = function () {

/**
*
* @param status { iterations: number, error: number}
* @param options
* @param {object} data
* @param {object} status { iterations: number, error: number }
* @param endTime
*/

}, {
Expand Down Expand Up @@ -1327,7 +1326,7 @@ var NeuralNetwork = function () {
* @param data
* @param options
* @private
* @return {{runTrainingTick: function, status: {error: number, iterations: number}}}
* @return {object}
*/

}, {
Expand Down Expand Up @@ -1438,8 +1437,7 @@ var NeuralNetwork = function () {
this.calculateDeltas(target);
this._adjustWeights();

var error = (0, _mse2.default)(this.errors[this.outputLayer]);
return error;
return (0, _mse2.default)(this.errors[this.outputLayer]);
}

/**
Expand Down Expand Up @@ -1830,8 +1828,10 @@ var NeuralNetwork = function () {
}
}
}
this._updateTrainingOptions(json.trainOpts);
this.setActivation();
if (json.hasOwnProperty('trainOpts')) {
this._updateTrainingOptions(json.trainOpts);
}
this.setActivation(this.activation || 'sigmoid');
return this;
}

Expand Down Expand Up @@ -13286,7 +13286,6 @@ module.exports = function () {
this.addFunction = null;
this.functions = null;
this.nativeFunctions = null;
this.copyData = true;
this.subKernels = null;
this.subKernelProperties = null;
this.subKernelNames = null;
Expand Down Expand Up @@ -13549,12 +13548,6 @@ module.exports = function () {
this._webGl = webGl;
return this;
}
}, {
key: 'setCopyData',
value: function setCopyData(copyData) {
this.copyData = copyData;
return this;
}

/**
* @memberOf BaseKernel#
Expand Down Expand Up @@ -15473,7 +15466,7 @@ module.exports = function (_KernelBase) {
var output = [];
output.result = this.renderOutput(outputTexture);
for (var _i = 0; _i < this.subKernels.length; _i++) {
output.push(new Texture(this.subKernelOutputTextures[_i], texSize, this.output, this._webGl));
output.push(new Texture(this.subKernelOutputTextures[_i], texSize, this.threadDim, this.output, this._webGl));
}
return output;
} else if (this.subKernelProperties !== null) {
Expand All @@ -15483,7 +15476,7 @@ module.exports = function (_KernelBase) {
var _i2 = 0;
for (var p in this.subKernelProperties) {
if (!this.subKernelProperties.hasOwnProperty(p)) continue;
_output[p] = new Texture(this.subKernelOutputTextures[_i2], texSize, this.output, this._webGl);
_output[p] = new Texture(this.subKernelOutputTextures[_i2], texSize, this.threadDim, this.output, this._webGl);
_i2++;
}
return _output;
Expand Down Expand Up @@ -15520,7 +15513,7 @@ module.exports = function (_KernelBase) {
var threadDim = this.threadDim;
var output = this.output;
if (this.outputToTexture) {
return new Texture(outputTexture, texSize, output, this._webGl);
return new Texture(outputTexture, texSize, this.threadDim, output, this._webGl);
} else {
var result = void 0;
if (this.floatOutput) {
Expand Down Expand Up @@ -15646,25 +15639,6 @@ module.exports = function (_KernelBase) {

/**
* @memberOf WebGLKernel#
* @name getSubKernelTexture
* @function
*
* @desc This uses *getTextureCache* to get the Texture Cache of the sub-kernel
*
* @param {String} name - Name of the subKernel
*
* @returns {Object} Texture cache for the subKernel
*
*/

}, {
key: 'getSubKernelTexture',
value: function getSubKernelTexture(name) {
return this.getTextureCache('SUB_KERNEL_' + name);
}

/**
* @memberOf WebGLKernel#
* @name getTextureCache
* @function
*
Expand All @@ -15679,10 +15653,6 @@ module.exports = function (_KernelBase) {
}, {
key: 'getTextureCache',
value: function getTextureCache(name) {
if (this.outputToTexture) {
// Don't retain a handle on the output texture, we might need to render on the same texture later
return this._webGl.createTexture();
}
if (this.textureCache.hasOwnProperty(name)) {
return this.textureCache[name];
}
Expand Down Expand Up @@ -15873,8 +15843,7 @@ module.exports = function (_KernelBase) {
case 'Texture':
{
var inputTexture = value;
var _dim2 = utils.getDimensions(inputTexture, true);

var _dim2 = inputTexture.dimensions;
var _size2 = inputTexture.size;

gl.activeTexture(gl.TEXTURE0 + this.argumentsLength);
Expand Down Expand Up @@ -17076,16 +17045,18 @@ module.exports = function () {
/**
* @desc WebGl Texture implementation in JS
* @constructor Texture
* @param {Object} texture
* @param {Array} size
* @param {Object} texture
* @param {Array} size
* @param dimensions
* @param {Array} output
* @param {Object} webGl
*/
function Texture(texture, size, output, webGl) {
function Texture(texture, size, dimensions, output, webGl) {
_classCallCheck(this, Texture);

this.texture = texture;
this.size = size;
this.dimensions = dimensions;
this.output = output;
this.webGl = webGl;
this.kernel = null;
Expand Down
26 changes: 13 additions & 13 deletions dist/neural-network.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/neural-network.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "brain.js",
"description": "Neural network library",
"version": "1.1.0",
"version": "1.1.1",
"author": "Heather Arthur <[email protected]>",
"repository": {
"type": "git",
Expand Down
Loading

0 comments on commit 4d94d16

Please sign in to comment.