Question: I ' m scratching my head on what to do next. While I ' m familiar with linear algrebra, the coding aspects are eluding me

I'm scratching my head on what to do next. While I'm familiar with linear algrebra, the coding aspects are eluding me. I'm trying to get it to run the sample test and it'll have to run 3 additional tests. What am I messing up here?
Implement the function below to update the perceptron given an input vector, label, and weight vector. Do not check if an update is necessary. This function
can assume that it is only called when an update should be performed. Hint: You simply need to implement wlarrw+yx.
In [13]: M def perceptron_update(x, y, w):
function w=perceptron_update(x,y,w);
Updates the perceptron weight vector w using }\textrm{x}\mathrm{ and }\textrm{y
Input:
x : input vector of d dimensions (d)
y : corresponding label (-1 or +1)
wl : weight vector of d dimensions
Output:
w:: weight vector after updating (d)
YOUR CODE HERE
w}=
i =0
if true
update i = i +1
m =0
for (x,y):
if y (wTx)=0 then
update w = w + yx
update m = m +1
if m =0 then
break
else if i is none then
break
w}=w+y*
raise NotImplementedError()
Little test
y =-1
x = np.random.randint(low =-2, high =2, size =10)
w = np.random.randint(low =0, high =2, size =10)*2-1
print(f'y\t={y}')
print(f'x\t={x}')
print(f'w_old\t={w}')
w_new = perceptron_update(x, y, w)
print(f'w_new\t={-{_new}')
File "", line 17
if true
^
SyntaxError: invalid syntax
I ' m scratching my head on what to do next.

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!