Question: I keep getting a syntax error here. Every time I address one, another crops up . First the colon after = 0 , then w

I keep getting a syntax error here. Every time I address one, another crops up. First the colon after =0, then w, then b. Maybe I haven't had enough coffee yet today, but I'm at a loss as to what's going on. Any suggestions?
In [45]: M def perceptron(xs, ys):
"""
function w=perceptron(xs,ys);
Returns the weight vector learned by the Perceptron classifier.
Input:
xs : n input vectors of d dimensions (nxd matrix)
ys : n labels (-1 or +1)
Output:
w : weight vector (d)
b : bias term
"""
n, d = xs.shape # so we have n input vectors, of d dimensions each
w = np.zeros(d)
b =0.0
max_iterations =100
for iteration in range(max_iterations):
indices = np.random.permutation(n)
xs = xs[indices]
ys = ys[indices]
converged = True
for i in range(n):
if ys[i]*(np.dot(w, xs[i]+ b)=0:
w += ys[i]*xs[i]
b += ys[i]
converged = False
if converged:
break
return w, b
raise NotImplementedError()
File "", line 28
if ys[i]*(np.dot(w, xs[i]+ b)=0:
^
SyntaxError: invalid syntax
I keep getting a syntax error here. Every time I

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!