Skip to content

Commit

Permalink
Merge 9bddbaa into 0874fff
Browse files Browse the repository at this point in the history
  • Loading branch information
raimannma authored Jan 1, 2020
2 parents 0874fff + 9bddbaa commit d5a0864
Show file tree
Hide file tree
Showing 17 changed files with 1,796 additions and 1,723 deletions.
1,200 changes: 694 additions & 506 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,24 @@
},
"homepage": "https://liquidcarrot.io/",
"dependencies": {
"lodash": "^4.17.15"
"lodash": "^4.17.15",
"riteway": "^6.1.1"
},
"devDependencies": {
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"chai-each": "0.0.1",
"chalk": "^2.4.2",
"copy-webpack-plugin": "^5.0.4",
"coveralls": "^3.0.6",
"copy-webpack-plugin": "^5.1.1",
"coveralls": "^3.0.9",
"faker": "^4.1.0",
"jsdoc": "^3.6.3",
"mocha": "^6.2.0",
"nodemon": "^1.19.2",
"mocha": "^6.2.2",
"nodemon": "^1.19.4",
"nyc": "^13.3.0",
"parallel-webpack": "^2.4.0",
"webpack": "^4.41.0",
"webpack-cli": "^3.3.9"
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10"
},
"nyc": {
"include": [
Expand Down
1 change: 1 addition & 0 deletions src/architecture/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function Connection (from, to, weight, options) {
delta_weights_total: 0,
delta_weights: [],
xtrace_nodes: [],
sharedIncoming: null,
xtrace_values: []
}, options, { from, to, weight});

Expand Down
989 changes: 417 additions & 572 deletions src/architecture/network.js

Large diffs are not rendered by default.

33 changes: 23 additions & 10 deletions src/architecture/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ function Node(options) {
incoming: [],
outgoing: [],
gated: [],
sharedIncoming: null,
connections_self: new Connection(self, self, 0),
error_responsibility: 0,
error_projected: 0,
error_gated: 0,
...options
...options,
})

/**
Expand Down Expand Up @@ -116,6 +117,9 @@ function Node(options) {
// DRY abstraction
const activate = function() {
// Activate (from self)
if (self.sharedIncoming !== null) {
self.bias = self.sharedIncoming.bias;
}
self.state = self.connections_self.gain * self.connections_self.weight * self.state + self.bias;

// Activate (from incoming connections)
Expand All @@ -124,7 +128,7 @@ function Node(options) {
self.state += conn.from.activation * conn.weight * conn.gain;
}

return self.state
return self.state;
}

if(options.trace) {
Expand Down Expand Up @@ -281,7 +285,6 @@ function Node(options) {
self.error_projected = 0;
for (let i = 0; i < self.outgoing.length; i++) {
const connection = self.outgoing[i];

self.error_projected += connection.to.error_responsibility * connection.weight * connection.gain;
}
self.error_projected *= self.derivative || 1;
Expand All @@ -293,7 +296,7 @@ function Node(options) {
const node = connection.to;
const influence = (node.connections_self.gater === self ? node.old : 0) + connection.weight * connection.from.activation;

self.error_gated += node.error_reponsibility * influence;
self.error_gated += node.error_responsibility * influence;
}
self.error_gated *= self.derivative || 1;

Expand All @@ -314,7 +317,9 @@ function Node(options) {
connection.delta_weights_total += options.rate * gradient * self.mask;
if (options.update) {
connection.delta_weights_total += options.momentum * connection.delta_weights_previous;
connection.weight += connection.delta_weights_total;
if (connection.sharedIncoming === null) {
connection.weight += connection.delta_weights_total;
}
connection.delta_weights_previous = connection.delta_weights_total;
connection.delta_weights_total = 0;
}
Expand All @@ -324,7 +329,9 @@ function Node(options) {
self.delta_bias_total += options.rate * self.error_responsibility;
if (options.update) {
self.delta_bias_total += options.momentum * self.delta_bias_previous;
self.bias += self.delta_bias_total;
if (self.sharedIncoming === null) {
self.bias += self.delta_bias_total;
}
self.delta_bias_previous = self.delta_bias_total;
self.delta_bias_total = 0;
}
Expand Down Expand Up @@ -699,11 +706,16 @@ function Node(options) {

switch(options.method) {
case methods.mutation.MOD_ACTIVATION:
if(options.allowed) self.squash = options.allowed[random_index(options.allowed.length, options.allowed.indexOf(self.squash))];
else self.squash = methods.activation[random_key(Object.keys(methods.activation), self.squash.name)]
if (options.allowed) {
self.squash = options.allowed[random_index(options.allowed.length, options.allowed.indexOf(self.squash))];
} else {
self.squash = methods.activation[random_key(Object.keys(methods.activation), self.squash.name)];
}
break;
case methods.mutation.MOD_BIAS:
self.bias += Math.random() * (options.method.max - options.method.min) + options.method.min;
if (self.sharedIncoming === null) {
self.bias += Math.random() * (options.method.max - options.method.min) + options.method.min;
}
break;
}
},
Expand Down Expand Up @@ -850,7 +862,8 @@ function Node(options) {
bias: self.bias,
type: self.type,
squash: self.squash.name,
mask: self.mask
mask: self.mask,
shared: self.shared,
};
}
}
Expand Down
Loading

0 comments on commit d5a0864

Please sign in to comment.