Skip to content

Instantly share code, notes, and snippets.

@miloharper
Created August 17, 2015 03:46
Show Gist options
  • Save miloharper/960a610947956832416f to your computer and use it in GitHub Desktop.
Save miloharper/960a610947956832416f to your computer and use it in GitHub Desktop.
Snippet of code showing the training function for a Neuron.
def train(self, previous_layer):
for synapse in self.synapses:
# Propagate the error back down the synapse to the neuron in the layer below
previous_layer.neurons[synapse.input_neuron_index].error += self.error * sigmoid_derivative(self.output) * synapse.weight
# Adjust the synapse weight
synapse.weight += synapse.signal * self.error * sigmoid_derivative(self.output)
return previous_layer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment