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 then w then b Maybe I haven't had enough coffee yet today, but Im at a loss as to what's going on Any suggestions?
In : M def perceptronxs ys:
function wperceptronxsys;
Returns the weight vector learned by the Perceptron classifier.
Input:
xs : n input vectors of d dimensions nxd matrix
ys : n labels or
Output:
w : weight vector d
b : bias term
n d xsshape # so we have n input vectors, of d dimensions each
w npzerosd
b
maxiterations
for iteration in rangemaxiterations:
indices nprandom.permutationn
xs xsindices
ys ysindices
converged True
for i in rangen:
if ysinpdotw xsi b:
w ysixsi
b ysi
converged False
if converged:
break
return w b
raise NotImplementedError
File line
if ysinpdotw xsi b:
SyntaxError: invalid syntax
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
