0
我正在學習python,但無法讓我的腦袋製作神經網絡的多個數組我得到的例子傾向於圍繞1個神經數組示例演變,並且我想創建很多。下面的是一個神經網絡如何我展開它在numpy的所以它是非常感謝的advance.Im試圖建立神經網絡陣列的羣各有其隱藏的輸入和輸出層8)創建多個神經網絡陣列
import numpy as np
epochs = 10000 # Number of iterations
inputLayerSize, hiddenLayerSize, outputLayerSize = 2,2,1
X = np.array([[0,0], [0,1], [1,0], [1,1]])
Y = np.array([ [0], [1], [1], [0]])
def sigmoid (x): return 1/(1 + np.exp(-x)) # activation function
def sigmoid_(x): return x * (1 - x) # derivative of sigmoid
# weights on layer inputs
Wh = np.random.uniform(size=(inputLayerSize, hiddenLayerSize))
Wz = np.random.uniform(size=(hiddenLayerSize,outputLayerSize))
for i in range(epochs):
H = sigmoid(np.dot(X, Wh)) # hidden layer results
Z = sigmoid(np.dot(H, Wz)) # output layer results
E = Y - Z # how much we missed #(error)
dZ = E * sigmoid_(Z) # delta Z
dH = dZ.dot(Wz.T) * sigmoid_(H) # delta H
Wz += H.T.dot(dZ) # update output layer #weights
Wh += X.T.dot(dH) # update hidden layer #weights
print("------") # what have we learnt?
#Walk-through
print(Z)
這似乎覆蓋正確巴布有什麼錯? 8)其次,當嘗試創建一個更大的數組時,它不會計算e = y-z 8)ps感謝您的幫助 –