공부 기록
Deep Learning(0902_day1) 본문
퍼셉트론¶
- AND 게이트
In [18]:
import numpy as np
def AND(x1, x2):
w1, w2, theta = 0.5, 0.5, 0.7
tmp = x1*w1 + x2*w2
if tmp <= theta:
return 0
elif tmp > theta:
return 1
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
print(AND(0, 0), AND(0, 1), AND(1, 0), AND(1, 1))
- NAND 게이트
In [31]:
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
print(NAND(0, 0), NAND(0, 1), NAND(1, 0), NAND(1, 1))
1 1 1 0
- OR 게이트
In [32]:
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
print(OR(0, 0), OR(0, 1), OR(1, 0), OR(1, 1))
0 1 1 1
In [33]:
def XOR(x1, x2):
s1 = NAND(x1, x2)
s2 = OR(x1, x2)
y = AND(s1, s2)
return y
print(XOR(0, 0), XOR(0, 1), XOR(1, 0), XOR(1, 1))
0 1 1 0
'playdata' 카테고리의 다른 글
Deep Learning(0906_day2) (0) | 2021.09.06 |
---|---|
Deep Learning(0903_day1) (0) | 2021.09.03 |
Computer Vision(0830_day8) (0) | 2021.08.30 |
Computer Vision(0826_day7) - 실습_Lane Finding Pipeline (0) | 2021.08.26 |
Computer Vision(0826_day7) (0) | 2021.08.26 |
Comments