을 사용하는 그래디언트 하강. 어떤 메신저 이후 알고리즘의 모든 루프를 피하고 있습니다 그래서 나는 행렬과 numpy.dot를 사용하여 계산을 수행합니다. 수학의 확인 임,하지만 난 오류 메시지가 얻을이 기능을 통과하려고 할 때마다 : 난 항상이 오류 얻을Nrady를 사용하여 Gradient Descent Algorithm을 구현하려는 메신저 컴퓨터 학습
def grad(feature_matrix, output, initial_weights, step_size, tolerance):
converged = False
w = np.array(initial_weights) # make sure it's a numpy array
X=feature_matrix
y=output
s=step_size
t=0
RSS=0
J=[]
while not converged:
y_h=np.dot(X,w)
e=y-_yh
w=w+s*2*np.dot(np.transpose(X),e)
gradient_magnitude=sqrt(np.dot(np.transpose(X),e)
RSS=np.dot(e,e)
J.append(RSS)
t=t+1
if gradient_magnitude < tolerance:
converged = True
return(weights,J,t)
:
File "<ipython-input-14-db210106141b>", line 15
RSS=np.dot(e,e)
^
SyntaxError: invalid syntax
a를 RSS = np.dot을 삭제하는 경우를 (E, E) 라인과, 기능을 전달하는 시도는 내가 얻을 :
File "<ipython-input-15-b0b1a5aebd0c>", line 16
J.append(RSS)
^
SyntaxError: invalid syntax
이 기능 구조 일 것 같다. 메신저가 빠진 것이 분명 할 수도 있지만 3 일 동안이 함수를 찾고 다른 예제를 보면 오류를 찾을 수 없습니다.
제발 도와주세요!
힌트 :이 경우, 이 라인에서 누락 된 닫는 괄호,
)
는, 거기 당신이 라인을 삭제하고 오류가 여전히 오류의 제거 라인 아니었다 지속되는 경우. 전에 한 줄 보렴 – miraculixx