8000 DL(1) 작성 완료 · mioscode/mioscode.github.io@4f97bbc · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f97bbc

Browse files
author
somee.han
committed
DL(1) 작성 완료
1 parent 98484e4 commit 4f97bbc

File tree

9 files changed

+159
-87
lines changed

9 files changed

+159
-87
lines changed

_posts/2019-11-14-DL(1)-perceptron.md

Lines changed: 113 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
2-
title: "딥러닝(1) - 개요, 퍼셉트론"
2+
title: "딥러닝(1) - 퍼셉트론"
33
categories:
44
- Deep Learning
55
tags:
66
- Perceptron
77
- Deep Learning
88
comments: true
99
---
10-
# 1. AI, DL, ML ... Neural Network
11-
## 인공지능(AI)의 역사
10+
# 1. 들어가기 전에
11+
## 1.1. AI의 역사
1212
- 1943년: 최초 신경망 모델 제안
1313
- 1950년: 앨런 튜링이 튜링 테스트 제안
1414
- (첫 번째 AI 붐) 1950년대 후반 ~ 1970년대 전반
@@ -19,7 +19,32 @@ comments: true
1919
- (세 번째 AI 붐) 2010년대: 딥 러닝 (머신 러닝)이라는 새로운 기술이 각광
2020
<center><img src="https://mioscode.github.io/assets/images/dl1/history.jpg" width="50%"></center>
2121

22-
## Deep Learning (Machine Learning)
22+
## 1.2. AI, ML, DL
23+
- AI(Artificial Intelligence): 사고나 학습 등 인간이 가진 지적 능력을 컴퓨터를 통해 구현하는 기술
24+
- ML(Machine Learning): 컴퓨터가 스스로 학습하여 인공지능의 성능을 향상시키는 기술
25+
- DL(Deep Learning): 인간의 뉴런과 비슷한 인공신경망 방식으로 정보를 처리하는 기술
26+
<center><img src="https://mioscode.github.io/assets/images/dl1/ai_ml_dl.png" width="50%"></center>
27+
28+
## 1.3. Machine Learning
29+
1. 먼저 그림과 같이 컴퓨터에게 문제와 답을 알려줍니다.
30+
2. 이후, 관련 문제를 내면 컴퓨터가 정답을 알아 맞추게 됩니다.
31+
> 이것이 가능한 이유는 컴퓨터가 데이터(문제) 답(label)으로 학습하며 직접 프로그램(알고리즘)을 작성하기 때문
32+
<center><img src="https://mioscode.github.io/assets/images/dl1/ml.png" width="50%"></center>
33+
34+
### 종류
35+
#### 1) 지도학습 (Supervised Learning)
36+
훈련데이터와 정답을 가지며, 데이터를 분류/예측하는 함수를 만들어내는 기계학습 방법
37+
- 분류: KNN(K-Nearest Neighbors), 나이브 베이즈, 결정트리, 서포트 벡터머신, 아프리오 알고리즘
38+
- 회귀: 선형회귀(Linear Regression), 신경망
39+
40+
#### 2) 비지도학습 (Unsupervised/Predictive Learning)
41+
정답없이 훈련데이터만 가지고 데이터로부터 숨겨진 패턴을 탐색하는 기계학습의 방법
42+
- 클러스터링: 연관규칙(apriori), k-means
43+
44+
#### 3) 강화학습 (Reinforcement Learning)
45+
어떤 환경에서 정의된 에이전트가 현재 상태를 인식하여 선택 가능한 행동들 중 보상을 최대화하는 행동 혹은 행동 순서를 선택하는 방법
46+
47+
## 1.4. Deep Learning
2348
- 딥 러닝은 최신 인공 신경망(Artificial neural network) 기술로 인간 두뇌의 메커니즘을 시뮬레이션
2449
- 인간의 뇌는 정보를 전달하기 위해 뉴런(neuron)과 뉴런들을 연결하는 시냅스(synapse)로 구성
2550
- 인공 신경망(또는 단순히 신경망이라고 함)은 이러한 뉴런과 시냅스를 모델링
@@ -43,7 +68,8 @@ comments: true
4368

4469
- 입력(input) 신호의 총합이 정해진 임계값($\theta$) 넘었을 때 $1$을 출력(output), 넘지 못하면 $0$ 또는 $-1$ 출력
4570
- 각 입력신호에 고유한 weight 부여되며 기계학습은 이 weight(입력을 조절하니 매개변수로도 볼 수 있음)의 값을 정하는 작업
46-
<center><img src="https://mioscode.github.io/assets/images/dl1/perceptron.png" width="50%"></center>
71+
72+
<center><img src="https://mioscode.github.io/assets/images/dl1/perceptron_1.png" width="50%"></center>
4773
<center><img src="https://mioscode.github.io/assets/images/dl1/perceptron_2.png" width="50%"></center>
4874
<center><img src="https://mioscode.github.io/assets/images/dl1/perceptron_3.png" width="50%"></center>
4975
<center><img src="https://mioscode.github.io/assets/images/dl1/perceptron_4.png" width="50%"></center>
@@ -72,37 +98,107 @@ b+w_1x_1+w_2x_2 \geqq 0 \Rightarrow 1
7298

7399
## 2.5. 퍼셉트론의 한계점
74100
- AND와 OR과 같은 선형 데이터는 분류 가능하지만, XOR과 같은 형태의 비선형 데이터는 분류가 불가능하다
75-
- AND 함수: x1과 x2 중 모두(and) 1일때 1을 출력
76-
|x1|x2|y|
101+
- AND 게이트: x1과 x2 중 모두(and) 1일때 1을 출력
102+
|$x_1$|$x_2$|$y$|
77103
|:-:|:-:|:-:|
78104
|0|0|0|
79105
|0|1|0|
80106
|1|0|0|
81107
|1|1|1|
82-
- OR 함수: x1과 x2 중 하나만(or) 1이면 1을 출력
83-
|x1|x2|y|
108+
```python
109+
def AND(x1, x2):
110+
x = np.array([x1,x2])
111+
w = np.array([0.5,0.5])
112+
theta = 0.7
113+
if np.sum(w*x) <= theta:
114+
return 0
115+
else:
116+
return 1
117+
118+
inputData = np.array([[0,0],[1,0],[0,1],[1,1]])
119+
120+
for x in inputData:
121+
print(x[0],", ",x[1]," ==> ",AND(x[0],x[1]), sep = '')
122+
```
123+
- OR 게이트: x1과 x2 중 하나만(or) 1이면 1을 출력
124+
|$x_1$|$x_2$|$y$|
84125
|:-:|:-:|:-:|
85126
|0|0|0|
86127
|0|1|1|
87128
|1|0|1|
88129
|1|1|1|
89-
- XOR 함수: x1과 x2 중 어느 한쪽이 1일 때만 1을 출력 (둘다 1이면 0 출력)
90-
|x1|x2|y|
130+
```python
131+
def OR(x1,x2):
132+
x = np.array([x1,x2])
133+
w = np.array([0.5,0.5])
134+
theta = 0
135+
if np.sum(w*x) <= theta:
136+
return 0
137+
else:
138+
return 1
139+
inputData = np.array([[0,0],[1,0],[0,1],[1,1]])
140+
141+
for x in inputData:
142+
print(x[0],", ",x[1]," ==> ",OR(x[0],x[1]), sep = '')
143+
```
144+
- NAND 게이트: x1과 x2 중 하나만(or) 0이면 1을 출력
145+
|$x_1$|$x_2$|$y$|
146+
|:-:|:-:|:-:|
147+
|0|0|1|
148+
|0|1|1|
149+
|1|0|1|
150+
|1|1|0|
151+
```python
152+
def NAND(x1,x2):
153+
x = np.array([x1,x2])
154+
w = np.array([-0.5,-0.5])
155+
theta = -0.7
156+
if np.sum(w*x) <= theta:
157+
return 0
158+
else:
159+
return 1
160+
inputData = np.array([[0,0],[1,0],[0,1],[1,1]])
161+
162+
for x in inputData:
163+
print(x[0],", ",x[1]," ==> ",OR(x[0],x[1]), sep = '')
164+
```
165+
- XOR 게이트: x1과 x2 중 어느 한쪽이 1일 때만 1을 출력 (둘다 1이면 0 출력)
166+
|$x_1$|$x_2$|$y$|
91167
|:-:|:-:|:-:|
92168
|0|0|0|
93169
|0|1|1|
94170
|1|0|1|
95171
|1|1|0|
96-
<center><img src="https://mioscode.github.io/assets/images/dl1/xor.gif" width="50%"></center>
172+
<center><img src="https://mioscode.github.io/assets/images/dl1/xor.gif" width="50%"></center>
97173

98174
- 한계점이 밝혀지면서 한동안 소외 받았고, 퍼셉트론을 제시한 로젠블랫은 자살 같은 사고로 세상을 떠났고 시간이 흐른 뒤에야 그의 업적이 재조명 받았다.
99175

100176
## 2.6. 다층 퍼셉트론을 통한 한계 극복
101-
102-
![](/Users/somi.han/Documents/Deep%20Learning/Perceptron_XOR.jpg)
103-
104-
105-
177+
- 단층 퍼셉트론: AND, OR, NAND 게이트와 같이 입력층에 가중치를 곱해 바로 출력되는 퍼셉트론
178+
<center><img src="https://mioscode.github.io/assets/images/dl1/perceptron.png" width="50%"></center>
179+
180+
- 다층 퍼셉트론: 퍼셉트론을 층으로 쌓은 것으로,입력층과 출력층 사이 은닉층이 존재하는 것
181+
<center><img src="https://mioscode.github.io/assets/images/dl1/multi_perceptron.png" width="50%"></center>
182+
183+
- 위와 같은 다층 퍼셉트론(AND, OR, NAND를 조합)으로 XOR 게이트를 구현할 수 있음
184+
<center><img src="https://mioscode.github.io/assets/im B1DC ages/dl1/XOR_1.png" width="50%"></center>
185+
<center><img src="https://mioscode.github.io/assets/images/dl1/gate.png" width="50%"></center>
186+
187+
|$x_1$|$x_2$|$s_1$|$s_2$|$y$|
188+
|:-:|:-:|:-:|:-:|:-:|
189+
|0|0|1|0|0|
190+
|0|1|1|1|1|
191+
|1|0|1|1|1|
192+
|1|1|0|1|0|
193+
194+
```python
195+
def XOR(x1, x2):
196+
return AND(NAND(x1,x2), OR(x1,x2))
197+
198+
inputData = np.array([[0,0],[1,0],[0,1],[1,1]])
199+
for x in inputData:
200+
print(x[0],", ",x[1]," ==> ",XOR(x[0],x[1]), sep = '')
201+
```
106202

107203
## Reference
108204
https://journal.jp.fujitsu.com/en/2016/02/09/01/

0 commit comments

Comments
 (0)
0