Skip to content

Instantly share code, notes, and snippets.

@robertleeplummerjr
Created August 8, 2016 13:45
Show Gist options
  • Select an option

  • Save robertleeplummerjr/ea2fa21deb7929fecd8d69f39a367055 to your computer and use it in GitHub Desktop.

Select an option

Save robertleeplummerjr/ea2fa21deb7929fecd8d69f39a367055 to your computer and use it in GitHub Desktop.
//current code
var h0 = this.multiply(hiddenMatrix.weight, inputVector, this);
var h1 = this.multiply(hiddenMatrix.transition, hiddenPrev, this);
var hiddenD = this.relu(this.add(this.add(h0, h1, this), hiddenMatrix.bias, this), this);
//psuedo strongeryly typed relationship of above code
hiddenMatrix.weight.next = inputVector;
hiddenMatrix.weight.action = multiply;
hiddenMatrix.transition.next = hiddenPrev;
hiddenMatrix.transition.action = multiply;
inputVector.next = hiddenPrev;
inputVector.action = add;
hiddenPrev.next = hiddenMatrix.bias;
hiddenPrev.action = add;
hidden.next = null;
hidden.action = relu;
function run(matrix) {
while (matrix.next !== null) {
matrix.action(matrix, matrix.next);
matrix = matrix.next;
}
if (matrix.action) {
matrix.action();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment