Professional Documents
Culture Documents
#Given Data
x1_input = [-1,-1,1,1]
x2_input = [-1,1,-1,1]
bias = [1,1,1,1]
y = [-1,1,1,-1]
In [2]:
#initialising weights and bias
w1 = (0)
w2 = (0)
init_b = (0)
In [3]:
#updating weight: CASE 1
x1,x2,b = (-1,-1,1)
y= (-1)
del_w1 = x1*y
del_w2 = x2*y
del_b = y
w1_new = w1 + del_w1
w2_new = w2 + del_w2
b_new = init_b + y
print(w1_new,w2_new,b_new)
1 1 -1
In [4]:
#taking updated weights of case 1 as initial weights for case 2
w1 = (1)
w2 = (1)
init_b = (-1)
In [5]:
#updating weight: CASE 2
x1,x2,b = (-1,1,1)
y= (1)
del_w1 = x1*y
del_w2 = x2*y
del_b = y
w1_new = w1 + del_w1
w2_new = w2 + del_w2
b_new = init_b + y
print(w1_new,w2_new,b_new)
020