Python Neural Network Basics
From https://iamtrask.github.io/2015/07/12/basic-python-network/
import numpy as np sigmoid function def nonlin(x,deriv=False): if(deriv==True): return x*(1-x) return 1/(1+np.exp(-x)) input dataset X = np.array([ [0,0,1], [0,1,1], [1,0,1], [1,1,1] ]) output dataset y = np.array([[0,0,1,1]]).T seed random numbers to make calculation deterministic (just a good practice)
np.random.seed(1) initialize weights randomly with mean 0 syn0 = 2*np.random.random((3,1)) - 1 print(syn0) ## [[-0.16595599] ## [ 0.44064899] ## [-0.99977125]] variables l0 is input layer l1 is hidden layer l1_error is the loss function l1_delta is the gradient descent function for calculating the back-propagation syn0 are synapses, weights between l0 and l1, and also how the weights are updated are shown.
[Read More]