1
我在參加Coursera的計算神經科學課。到目前爲止,它一直很棒!但是,我遇到了一個測驗問題。尋找線性復發網絡的穩態輸出
我沒有參加這個課程的證書或任何東西。純粹是爲了好玩。我已經參加了測驗,過了一段時間,我猜對了答案,所以這甚至不會回答測驗。
問題的框架如下: 假設我們有一個包含5個輸入節點和5個輸出節點的線性遞歸網絡。讓我們說,我們的網絡的權重矩陣W是:(。從本質上講,所有0.1,除了0.6對角線上)
W = [0.6 0.1 0.1 0.1 0.1]
[0.1 0.6 0.1 0.1 0.1]
[0.1 0.1 0.6 0.1 0.1]
[0.1 0.1 0.1 0.6 0.1]
[0.1 0.1 0.1 0.1 0.6]
假設我們有一個靜態的輸入向量u:
u = [0.6]
[0.5]
[0.6]
[0.2]
[0.1]
最後,假設我們有一個經常性的權重矩陣M:
M = [-0.25, 0, 0.25, 0.25, 0]
[0, -0.25, 0, 0.25, 0.25]
[0.25, 0, -0.25, 0, 0.25]
[0.25, 0.25, 0, -0.25, 0]
[0, 0.25, 0.25, 0, -0.25]
以下哪項是網絡的穩態輸出v_ss? (提示:見覆髮網絡講座,並考慮寫一些八度或Matlab代碼來處理特徵向量/值(您可以使用「EIG」功能))」
該類可將筆記發現here。具體而言,可以在幻燈片5和6上找到穩態公式的公式。
我有以下代碼。
import numpy as np
# Construct W, the network weight matrix
W = np.ones((5,5))
W = W/10.
np.fill_diagonal(W, 0.6)
# Construct u, the static input vector
u = np.zeros(5)
u[0] = 0.6
u[1] = 0.5
u[2] = 0.6
u[3] = 0.2
u[4] = 0.1
# Connstruct M, the recurrent weight matrix
M = np.zeros((5,5))
np.fill_diagonal(M, -0.25)
for i in range(3):
M[2+i][i] = 0.25
M[i][2+i] = 0.25
for i in range(2):
M[3+i][i] = 0.25
M[i][3+i] = 0.25
# We need to matrix multiply W and u together to get h
# NOTE: cannot use W * u, that's going to do a scalar multiply
# it's element wise otherwise
h = W.dot(u)
print 'This is h'
print h
# Ok then the big deal is:
# h dot e_i
# v_ss = sum_(over all eigens) ------------ e_i
# 1 - lambda_i
eigs = np.linalg.eig(M)
eigenvalues = eigs[0]
eigenvectors = eigs[1]
v_ss = np.zeros(5)
for i in range(5):
v_ss += (np.dot(h,eigenvectors[:, i]))/((1.0-eigenvalues[i])) * eigenvectors[:,i]
print 'This is our steady state v_ss'
print v_ss
正確的答案是:
[0.616, 0.540, 0.609, 0.471, 0.430]
這就是我得到:
This is our steady state v_ss
[ 0.64362264 0.5606784 0.56007018 0.50057043 0.40172501]
誰能發現我的錯誤?非常感謝!我非常感謝,併爲博客文章發表了長長的道歉。本質上,所有你需要看,是在頂部鏈接上的幻燈片5和6。
我不知道該聯繫誰。你有信心在我的程序中正確回答這個問題嗎?我懷疑Coursera會爲一羣人提出錯誤的解決方案。我覺得我的代碼必須有錯誤,或者我必須在邏輯中存在缺陷。 – jlarks32