Skip to content

Instantly share code, notes, and snippets.

@mempirate
Last active March 27, 2018 14:52
Show Gist options
  • Save mempirate/c08c0ec116182010084772bc7ee2f67c to your computer and use it in GitHub Desktop.
Save mempirate/c08c0ec116182010084772bc7ee2f67c to your computer and use it in GitHub Desktop.
# Train by iterating 10,000 times
for iteration in range(10000):
# Define input layer
input_layer = training_inputs
# Normalize the product of the input layer with the synaptic
# weights by using the sigmoid function to get outputs
outputs = sigmoid(np.dot(input_layer, synaptic_weights))
# Calculate the error
error = training_outputs - outputs
# Multiply how much we missed by the slope of the sigmoid at the values in outputs
adjustments = error * sigmoid_derivative(outputs)
# Update the weights using our adjustments
synaptic_weights += np.dot(input_layer.T, adjustments)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment