[英]Why isn't the value of this array not changing?
我正在嘗試對機器學習算法進行矢量化處理,但臨時數組未更改值。
我已經嘗試用變量替換臨時變量,並且它可以工作,但是我想看看為什么它不能與數組一起工作。
def step_gradient(theta, x_values, y_values, learningRate):
temp_theta = np.array([0, 0])
error = ((x_values * theta[1]) + theta[0]) - y_values
errorM = np.dot(error, x_values)
error = sum(error) #error works
#below is the problem
#theta 1 - error... does = 0.75
temp_theta[1] = theta[1] - ((errorM/len(x_values)) * learningRate)
temp_theta[0] = theta[0] - ((error/len(x_values)) * learningRate)
theta[1] = temp_theta[1]
theta[0] = temp_theta[0]
return theta
我希望temp_theta的值能夠改變,但保持不變
我檢查了一下
((error/len(x_values)) * learningRate)
不等於零。 由於某些原因, temp_theta[0]'s
值不會更改。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.