Skip to content

Instantly share code, notes, and snippets.

@robertleeplummerjr
Last active December 7, 2017 14:53
Show Gist options
  • Save robertleeplummerjr/4aaf8afb177c9c80f8452d5025117e26 to your computer and use it in GitHub Desktop.
Save robertleeplummerjr/4aaf8afb177c9c80f8452d5025117e26 to your computer and use it in GitHub Desktop.
a brain.js feed-forward layer
import {
add,
multiply,
random,
sigmoid
} from './';
export default function feedForward(settings, input) {
const { width, height } = settings;
const weights = random({ width, height });
const bias = random({ width });
return sigmoid(
add(
multiply(
input,
weights
),
bias
)
);
}
@robertleeplummerjr
Copy link
Author

No talk of tensors, matrices, no gpu's, though it has all that. Just sweet sweet simple math with a little programming.

@robertleeplummerjr
Copy link
Author

robertleeplummerjr commented Dec 7, 2017

This will be available soon, and usable like:

import {
  input as inputLayer,
  feedForward as FeedForwardLayer,
  output as outputLayer
} from 'brain.js/layer';

const net = new brain.FeedForward({
  inputLayer: (input) => inputLayer({ width: inputWidth }, input),
  hiddenLayers: => [
    (input) => feedForwardLayer({ width: inputWidth, height: hiddenHeight }, input)
  ],
  outputLayer: {input) => outputLayer({ width: outputWidth })
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment