我无法正常工作。我不知道出什么问题了。它一直告诉我m_loss_slope行中有一个无效的语法
b1 = random.randn()
m1 = random.randn()
learning_rate = 0.001
epochs = 10000
N = float(len(points))
print(b1)
print(m1)
for n in range(0, epochs):
for i in range(0, len(points)):
x = points[i, 0]
y = points[i, 1]
b_loss_slope += (-2/N) * (y - ((m * x) + b)
m_loss_slope += (-2/N) * (x * (y - ((m * x) + b)))
print(b_loss_slope)
print(m_loss_slope)
b1 = b1 - (learning_rate * b_loss_slope)
m1 = m1 - (learning_rate * b_loss_slope)
print(b1)
print(m1)
这是我不断收到的错误:
m_loss_slope += (-2/N) * (x * (y - ((m * x) + b)))
^
SyntaxError: invalid syntax
帮助将不胜感激 谢谢
答案 0 :(得分:0)
该行:
b_loss_slope += (-2/N) * (y - ((m * x) + b)
在末尾需要一个额外的右括号)
:
b_loss_slope += (-2/N) * (y - ((m * x) + b))