Last active
May 3, 2018 14:14
-
-
Save wutania/47c9f88c739056d818d3515b6302fdcb to your computer and use it in GitHub Desktop.
COMP4332-hw2-q3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
w1 = 0.3 | |
w2 = 0.3 | |
b = 0.3 | |
x1 = 2 | |
x2 = 0 | |
a = 0.6 | |
ex = 0 | |
net = w1 * x1 + w2 * x2 + b | |
y = 1/(1+(2.7183**(-net))) | |
w1 = w1 + a *(ex - y)*x1 | |
w2 = w2 + a *(ex - y)*x2 | |
b = b + a * (ex - y) | |
print ("w1: ", w1, " w2: ", w2, " b: ", b, " y: ",y) | |
x1 = 0 | |
x2 = 2 | |
ex = 0 | |
net = w1 * x1 + w2 * x2 + b | |
y = 1/(1+(2.7183**(-net))) | |
w1 = w1 + a *(ex - y)*x1 | |
w2 = w2 + a *(ex - y)*x2 | |
b = b + a * (ex - y) | |
print ("w1: ", w1, " w2: ", w2, " b: ", b, " y: ",y) | |
x1 = 4 | |
x2 = 2 | |
ex = 1 | |
net = w1 * x1 + w2 * x2 + b | |
y = 1/(1+(2.7183**(-net))) | |
w1 = w1 + a *(ex - y)*x1 | |
w2 = w2 + a *(ex - y)*x2 | |
b = b + a * (ex - y) | |
print ("w1: ", w1, " w2: ", w2, " b: ", b, " y: ",y) | |
x1 = 2 | |
x2 = 4 | |
ex = 1 | |
net = w1 * x1 + w2 * x2 + b | |
y = 1/(1+(2.7183**(-net))) | |
w1 = w1 + a *(ex - y)*x1 | |
w2 = w2 + a *(ex - y)*x2 | |
b = b + a * (ex - y) | |
print ("w1: ", w1, " w2: ", w2, " b: ", b, " y: ",y) | |
x1 = 2 | |
x2 = 0 | |
ex = 0 | |
net = w1 * x1 + w2 * x2 + b | |
y = 1/(1+(2.7183**(-net))) | |
w1 = w1 + a *(ex - y)*x1 | |
w2 = w2 + a *(ex - y)*x2 | |
b = b + a * (ex - y) | |
print ("w1: ", w1, " w2: ", w2, " b: ", b, " y: ",y) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment