2021年5月3日星期一

Operation "@" in multiply vectors gives Syntax Error

When I tried used in Google Colab this part code:

def costFunction(X, Y, theta):      scalar=1;      '''      Calcular la Least Square Cost Function.      Devolver la funcion calculada.      '''      X=np.insert(X.T, 0, np.ones(X.shape[1]), 1)      theta=theta.T      cost = 0.5 @ (X @ theta-Y.T).T@(X@theta-Y.T)+theta.T@scalar@theta      return cost  

Gives the error:

 >   File "<ipython-input-8-c78bf44930a0>", line 9      >     cost = 0.5 @ (X @ theta-Y.T).T@(X@theta-Y.T)+theta.T@scalar@theta                   ^  SyntaxError: invalid syntax  
https://stackoverflow.com/questions/67378656/operation-in-multiply-vectors-gives-syntax-error May 04, 2021 at 12:04PM

没有评论:

发表评论