我正在尝试使用Python从Andrew Ng机器学习课程中找到优化的theta值以最小化成本函数。我的程序中的theta值不正确。我在这里看不懂什么?我正在尝试在这里学习...抱歉菜鸟问题
#Shapes of numpy arrays
#popx=(97,1)
#popxx=(97,2)#x in function
#profy=(97,1)#y in function
def gradientDescent(x,y,iterations=1500,alpha=0.01,theta=np.zeros(2).reshape(1,2)):
cost=np.zeros(iterations)
theta_Hist=[]
m=len(profy)
for i in range(iterations):
print("Before Loop\n",theta)
t=(alpha/m)*np.dot(popx.T,(np.dot(x,theta.T)-y))
print(np.dot(popx.T,theta.T)-y)))
theta=theta-t
theta_Hist.append(theta)
print("after\n",theta)
cost[i]=computeCost(x,theta)
gradientDescent(popxx,profy)
theta的值应为-3.24140214,1.1272942