Neural Networks with 3 layers and (3,2,2) number of nodes


In [24]:
import numpy as np
import math
import matplotlib.pyplot as plt
%matplotlib inline

In [28]:
#Layer 1 - input
print ("Layer 1")
X1 = np.array ([1,2.00,2.26]
               )
print ("X1 =", X1)


Layer 1
X1 = [ 1.    2.    2.26]

In [29]:
# Layer 2 
print ("Layer2")
print ("X1 =", X1)
W12 = np.array ([[12.70, -.20, -.74, -.19],
                [-1.49, -8.85, 7.08, -8.29],
                [-19.85, -2.61, -3.59, -2.70]])
#W1 = np.random.randn(4, 3)

W12
print ("W12 =") 
print (W12)
Y2 = X1.dot(W12)
print ("Y2 =", Y2)
A2 =1/(1+np.exp(-Y2))
print ("A2 =", A2)


Layer2
X1 = [ 1.    2.    2.26]
W12 =
[[ 12.7   -0.2   -0.74  -0.19]
 [ -1.49  -8.85   7.08  -8.29]
 [-19.85  -2.61  -3.59  -2.7 ]]
Y2 = [-35.141  -23.7986   5.3066 -22.872 ]
A2 = [  5.47592652e-16   4.61741961e-11   9.95065710e-01   1.16631701e-10]

In [30]:
# Layer 3 
print ("Layer3")

print ("A2 =", A2)
W23 = np.array ([7.44,2.78,-4.31,-2.70])
#W3 = np.random.randn(2, 3)
print ("W23 =") 
print (W23)
Y3 = A2.dot(W23) 
print ("Y3 =", Y3)
A3 =1/(1+np.exp(-Y3))
print ("A3 =", A3)


Layer3
A2 = [  5.47592652e-16   4.61741961e-11   9.95065710e-01   1.16631701e-10]
W23 =
[ 7.44  2.78 -4.31 -2.7 ]
Y3 = -4.28873321065
A3 = 0.0135365450529

In [ ]:


In [ ]: