Share
Sign In

2. 퍼셉트론

퍼셉트론: 다수의 신호를 입력으로 받아 하나의 신호를 출력
입력(x1, x2,..), 가중치(w1, w2,...), 와 편향(b) 로 이루어져 있고 y(0, 1)라는 출력이 나온다
# naive def AND(x1, x2): w1, w2, theta = 0.5, 0.5, 0.7 tmp = w1*x1 + w2*x2 if tmp <= theta: return 0 else: return 1 # use np def AND(x1, x2): x = np.array([x1, x2]) w = np.array([.5, .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 temp = np.sum(w*x) + b if temp <= 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 temp = np.sum(w*x) + b if temp <= 0: return 0 else: return 1
퍼셉트론의 한계: 선형구조가 아니면 구현 불가능.
이를 해결하기 위해 다층 퍼셉트론을 사용함
def XOR(x1, x2): s1 = NAND(x1, x2) s2 = OR(x1, x2) y = AND(s1, s2) return y