[問題] 神經網路 3 input 2 hidden 1 output已刪文

看板Python作者 (魚魚魚)時間6年前 (2018/12/31 09:04), 6年前編輯推噓2(205)
留言7則, 4人參與, 6年前最新討論串1/1
請教各位,我想創造一個神經網絡包含 3 inputs 2 hidden nodes 1 output import numpy as np x = np.array([0.5, -0.2, 0.1]) y = np.array([0.4]) test_w_i_h = np.array([[0.1, -0.2], [0.4, 0.5], [-0.3, 0.2]]) test_w_h_o = np.array([[0.3], [-0.1]]) delta_weights_i_h = np.zeros(test_w_i_h.shape) delta_weights_h_o = np.zeros(test_w_h_o.shape) activation_function = lambda x : 1/(1 + np.exp(-x)) hidden_inputs = np.dot(x, test_w_i_h) hidden_outputs = activation_function(hidden_inputs) final_inputs = np.dot(hidden_outputs, test_w_h_o) final_outputs = activation_function(final_inputs) error = y - final_outputs hidden_error = error * final_outputs * (1 - final_outputs) * test_w_h_o output_error_term = error * final_outputs * (1 - final_outputs) hidden_error_term = hidden_outputs[:, None] * (1 - hidden_outputs[:, None]) * hidden_error delta_weights_i_h += hidden_error_term.T * x[:, None] delta_weights_h_o += output_error_term * hidden_outputs[:,None] 但是在更新 Weight 時卻總是與預期答案不相符,想請問我是哪裡寫錯了? 提供p幣 100 拜託大家了 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.141.2.28 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1546218296.A.37A. ※ 編輯: fishworm (220.141.2.28), 12/31/2018 09:08:56

12/31 10:00, 6年前 , 1F
怎麼不用TensorFlow之類的庫呢?
12/31 10:00, 1F

12/31 10:08, 6年前 , 2F
在自己練習觀念,但發現好像有地方沒想通
12/31 10:08, 2F

12/31 10:12, 6年前 , 3F
如果是多層感知器(MLP)的結構那你缺了偏差(Bias)
12/31 10:12, 3F

12/31 10:33, 6年前 , 4F
通常是矩陣用錯或上面說的bias, 你先逐步檢查哪一步跟你預
12/31 10:33, 4F

12/31 10:33, 6年前 , 5F
期的結果不同再來說吧
12/31 10:33, 5F

12/31 11:29, 6年前 , 6F
好的,感謝兩位,我先回去檢查我的矩陣
12/31 11:29, 6F

12/31 14:32, 6年前 , 7F
與預期答案不符是什麼意思? 你預期哪裡會有怎樣的答案
12/31 14:32, 7F
文章代碼(AID): #1SAMiuDw (Python)
文章代碼(AID): #1SAMiuDw (Python)