1. 퍼셉트론 Perceptron
1-1. 퍼셉트론이란? What is Perceptron
퍼셉트론: 여러 개의 신호를 입력 받고 하나의 신호를 출력받음
$x, y, z$: 입력 신호 input signal
$w_{0}, w_{1}, w_{2}$: 가중치 weight
퍼셉트론의 동작 함수는 아래와 같음
$$y=\left\{\begin{matrix}
1 (b+w_{0}x+w_{1}y+w_{2}z> 0)
\\
0 (b+w_{0}x+w_{1}y+w_{2}z\leq 0)
\end{matrix}\right.$$
이때, $b$는 편향 bias라고 함
즉, 입력 신호에 가중치를 곱해 더한 값이 편향보다 크면 1을, 아니면 0을 출력하는 함수
1-2. 퍼셉트론으로 논리 회로 구현 Implement Logic Gates with Perceptron
- AND gate
import numpy as np
def AND(x1, x2):
x = np.array([x1, x2]) # input signals
w = np.array([0.5, 0.5]) # weights
b = -0.7 # bias
tmp = np.sum(w*x)+b
if tmp <= 0:
return 0
else:
return 1
- NAND gate
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
- OR gate
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 gate
XOR gate은 비선형 영역으로 구분되므로 다층 퍼셉트론으로 구현해야 함
def XOR(x1, x2):
s1 = NAND(x1, x2)
s2 = OR(x1, x2)
y = AND(s1, s2)
return y
print(XOR(0, 0)) # 0
print(XOR(1, 0)) # 1
print(XOR(0, 1)) # 1
print(XOR(1, 1)) # 0
Textbook used -> book.interpark.com/product/BookDisplay.do?_method=detail&sc.prdNo=263500510&gclid=EAIaIQobChMImIeshoSn7wIVWVtgCh0sqQ6IEAYYASABEgLGm_D_BwE
싸니까 믿으니까 인터파크도서
파이썬으로 익히는 딥러닝 이론과 구현 새로운 지식을 배울 때 설명만 들어서는 석연치 않거나 금방 잊어버리게 됩니다. 그래서 무엇보다 '직접 해보는 것'이 중요합니다. 이 책은 딥러닝의 기
book.interpark.com
<Source>
www.allaboutcircuits.com/technical-articles/how-to-train-a-basic-perceptron-neural-network/