Skip to content

Instantly share code, notes, and snippets.

@miloharper
Created August 17, 2015 03:51
Show Gist options
  • Save miloharper/64437344fd1428806332 to your computer and use it in GitHub Desktop.
Save miloharper/64437344fd1428806332 to your computer and use it in GitHub Desktop.
Snippet of code which shows how the neural network trains.
def train(self, example):
self.reset_errors()
error = example.output - self.think(example.inputs)
self.layers[-1].neurons[0].error = error
for l in range(len(self.layers) - 1, 0, -1):
for neuron in self.layers[l].neurons:
self.layers[l - 1] = neuron.train(self.layers[l - 1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment