Created
December 22, 2017 11:40
-
-
Save rscarrera27/b6a3f2e89ff05e03b76326f118191d39 to your computer and use it in GitHub Desktop.
다층 퍼셉트론을 응용한 XOR분류
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
def AND(x1, x2): | |
x = np.array([x1, x2]) | |
w = np.array([0.5, 0.5]) | |
b = -0.7 | |
tmp = np.sum(w*x) + b | |
if tmp <= 0: | |
return 0 | |
else: | |
return 1 | |
def NAND(x1, x2): | |
x = np.array([x1, x2]) | |
w = np.array([-0.5, -0.5]) | |
b = 0.7 | |
tmp = np.sum(w*x) + b | |
if tmp <= 0: | |
return 0 | |
else: | |
return 1 | |
def OR(x1, x2): | |
x = np.array([x1, x2]) | |
w = np.array([0.5, 0.5]) | |
b = 0.2 | |
tmp = np.sum(w*x) + b | |
if tmp <= 0: | |
return 0 | |
else: | |
return 1 | |
#XOR | |
def XOR(x1, x2): | |
s1 = NAND(x1, x2) | |
s2 = OR(x1, x2) | |
y = AND(s1, s2) | |
return y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment