Skip to content

Commit

Permalink
With some of the changes pushed up recently, NeuralNetworkGPU lagged …
Browse files Browse the repository at this point in the history
…behind. This was mainly the prepending of "_" to internal-only methods, as well as moving things to a `trainOpts` object. This meant that the GPU was not able to work at all. This catches things up.
  • Loading branch information
perkyguy committed Feb 5, 2018
1 parent 9d957e6 commit 8bf1f7f
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
20 changes: 10 additions & 10 deletions browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,9 @@ var NeuralNetworkGPU = function (_NeuralNetwork) {


_createClass(NeuralNetworkGPU, [{
key: 'initialize',
value: function initialize(sizes) {
_get(NeuralNetworkGPU.prototype.__proto__ || Object.getPrototypeOf(NeuralNetworkGPU.prototype), 'initialize', this).call(this, sizes);
key: '_initialize',
value: function _initialize(sizes) {
_get(NeuralNetworkGPU.prototype.__proto__ || Object.getPrototypeOf(NeuralNetworkGPU.prototype), '_initialize', this).call(this, sizes);
this.buildRunInput();
this.buildCalculateDeltas();
this.buildGetChanges();
Expand All @@ -485,9 +485,9 @@ var NeuralNetworkGPU = function (_NeuralNetwork) {
*/

}, {
key: 'trainPattern',
value: function trainPattern(input, target, learningRate) {
learningRate = learningRate || this.learningRate;
key: '_trainPattern',
value: function _trainPattern(input, target, learningRate) {
learningRate = learningRate || this.trainOpts.learningRate;
// forward propagate
this.runInput(input);

Expand Down Expand Up @@ -639,7 +639,7 @@ var NeuralNetworkGPU = function (_NeuralNetwork) {
key: 'getChanges',
value: function getChanges(learningRate) {
for (var layer = 1; layer <= this.outputLayer; layer++) {
var output = this.changesPropagate[layer](this.outputs[layer - 1], this.deltas[layer], this.weights[layer], this.changes[layer], learningRate, this.momentum);
var output = this.changesPropagate[layer](this.outputs[layer - 1], this.deltas[layer], this.weights[layer], this.changes[layer], learningRate, this.trainOpts.momentum);

this.changes[layer] = output.changes;
this.weights[layer] = output.weights;
Expand Down Expand Up @@ -701,8 +701,8 @@ var NeuralNetworkGPU = function (_NeuralNetwork) {
*/

}, {
key: 'formatData',
value: function formatData(data) {
key: '_formatData',
value: function _formatData(data) {
var _this2 = this;

if (!Array.isArray(data)) {
Expand Down Expand Up @@ -1286,7 +1286,7 @@ var NeuralNetwork = function () {
}, {
key: '_prepTraining',
value: function _prepTraining(data, options) {
this.updateTrainingOptions(options);
this._updateTrainingOptions(options);
data = this._formatData(data);
var endTime = Date.now() + this.trainOpts.timeout;

Expand Down
8 changes: 4 additions & 4 deletions browser.min.js

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions dist/neural-network-gpu.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-gpu.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 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.

12 changes: 6 additions & 6 deletions src/neural-network-gpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export default class NeuralNetworkGPU extends NeuralNetwork {
*
* @param {Number[]} sizes
*/
initialize(sizes) {
super.initialize(sizes);
_initialize(sizes) {
super._initialize(sizes);
this.buildRunInput();
this.buildCalculateDeltas();
this.buildGetChanges();
Expand All @@ -39,8 +39,8 @@ export default class NeuralNetworkGPU extends NeuralNetwork {
* @param target
* @param learningRate
*/
trainPattern(input, target, learningRate) {
learningRate = learningRate || this.learningRate;
_trainPattern(input, target, learningRate) {
learningRate = learningRate || this.trainOpts.learningRate;
// forward propagate
this.runInput(input);

Expand Down Expand Up @@ -205,7 +205,7 @@ export default class NeuralNetworkGPU extends NeuralNetwork {
this.weights[layer],
this.changes[layer],
learningRate,
this.momentum
this.trainOpts.momentum
);

this.changes[layer] = output.changes;
Expand Down Expand Up @@ -264,7 +264,7 @@ export default class NeuralNetworkGPU extends NeuralNetwork {
* @param data
* @returns {*}
*/
formatData(data) {
_formatData(data) {
if (!Array.isArray(data)) { // turn stream datum into array
let tmp = [];
tmp.push(data);
Expand Down

0 comments on commit 8bf1f7f

Please sign in to comment.