M.L code(p.85)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
#p85 - p88 import numpy as np from p69 import sigmoid #identity function def def identity_function(x): return x # first layer X = np.array([1.0, 0.5]) W1 = np.array([[0.1, 0.3, 0.5], [0.2,0.4,0.6]]) B1 = np.array([0.1, 0.2, 0.3]) print(X.shape) print(W1.shape) print(B1.shape) A1 = np.dot(X,W1) + B1 print(A1) Z1 = sigmoid(A1) print(Z1) # second layer W2 = np.array([[0.1,0.4], [0.2,0.5], [0.3,0.6]]) B2 = np.array([0.1, 0.2]) print(Z1.shape) print(W2.shape) print(B2.shape) A2 = np.dot(Z1,W2) + B2 print(A2) Z2 = sigmoid(A2) print(Z2) W3 = np.array([[0.1, 0.3], [0.2,0.4]]) B3 = np.array([0.1,0.2]) A3 = np.dot(Z2,W3) + B3 print(identity_function(A3)) |
third layer neural networks