Skip to content

Instantly share code, notes, and snippets.

@george-polevoy
Created January 23, 2021 22:37
Show Gist options
  • Save george-polevoy/53bce3ccfc7a39717852e9ce62a4ea18 to your computer and use it in GitHub Desktop.
Save george-polevoy/53bce3ccfc7a39717852e9ce62a4ea18 to your computer and use it in GitHub Desktop.
Simple Neural Network routine
public double[] FeedForward(double[] inputs)
{
for (int i = 0; i < inputs.Length; i++)
{
neurons[0][i] = inputs[i];
}
for (int i = 1; i < layers.Length; i++)
{
for (int j = 0; j < neurons[i].Length; j++)
{
double value = 0f;
for (int k = 0; k < neurons[i - 1].Length; k++)
{
value += weights[i - 1][j][k] * neurons[i - 1][k];
}
neurons[i][j] = activate(i, value + biases[i][j]);
}
}
return neurons[neurons.Length - 1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment