Skip to content

Instantly share code, notes, and snippets.

View mempirate's full-sized avatar

Jonas Bostoen mempirate

  • Antwerp, Belgium
  • 18:06 (UTC +02:00)
  • X @mempirate
View GitHub Profile
# 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))
# Set seed for pseudo-randomness
np.random.seed(1)
# Initialize synaptic weights randomly from -1 to 1 with 0 as the mean
synaptic_weights = 2 * np.random.random((3, 1)) - 1
# Input matrix
training_inputs = np.array([[0,0,1],
[1,1,1],
[1,0,1],
[0,1,1]])
# Output array (transposed)
training_outputs = np.array([[0,1,1,0]]).T
import numpy as np
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def sigmoid_derivative(x):
return x * (x - 1)
Verifying my Blockstack ID is secured with the address 1Jzq7PkwGH34a6iF1PAL6QVuQqatY6MxZy https://explorer.blockstack.org/address/1Jzq7PkwGH34a6iF1PAL6QVuQqatY6MxZy