@@ -17,19 +17,19 @@ comments: true
17
17
- (두 번째 AI 붐) 1980년대: 주로 컴퓨터가 자율적으로 배우고 결정하는 종류가 아닌 인간으로부터 지식을 얻음
18
18
- 1990년대: 세계 체스 챔피언을 물리 친 AI
19
19
- (세 번째 AI 붐) 2010년대: 딥 러닝 (머신 러닝)이라는 새로운 기술이 각광
20
- <center ><img src =" https://mioscode.github.io/assets/images/dl1/history.jpg " width =" 50 %" ></center >
20
+ <center ><img src =" https://mioscode.github.io/assets/images/dl1/history.jpg " width =" 70 %" ></center >
21
21
22
22
## 1.2. AI, ML, DL
23
23
- AI(Artificial Intelligence): 사고나 학습 등 인간이 가진 지적 능력을 컴퓨터를 통해 구현하는 기술
24
24
- ML(Machine Learning): 컴퓨터가 스스로 학습하여 인공지능의 성능을 향상시키는 기술
25
25
- DL(Deep Learning): 인간의 뉴런과 비슷한 인공신경망 방식으로 정보를 처리하는 기술
26
- <center ><img src =" https://mioscode.github.io/assets/images/dl1/ai_ml_dl.png " width =" 50 %" ></center >
26
+ <center ><img src =" https://mioscode.github.io/assets/images/dl1/ai_ml_dl.png " width =" 70 %" ></center >
27
27
28
28
## 1.3. Machine Learning
29
29
1 . 먼저 그림과 같이 컴퓨터에게 문제와 답을 알려줍니다.
30
30
2 . 이후, 관련 문제를 내면 컴퓨터가 정답을 알아 맞추게 됩니다.
31
31
> 이것이 가능한 이유는 컴퓨터가 데이터(문제) 답(label)으로 학습하며 직접 프로그램(알고리즘)을 작성하기 때문
32
- <center> <img src =" https://mioscode.github.io/assets/images/dl1/ml.png " width =" 50 %" ></center >
32
+ <center> <img src =" https://mioscode.github.io/assets/images/dl1/ml.png " width =" 70 %" ></center >
33
33
34
34
### 종류
35
35
#### 1) 지도학습 (Supervised Learning)
@@ -49,7 +49,7 @@ comments: true
49
49
- 인간의 뇌는 정보를 전달하기 위해 뉴런(neuron)과 뉴런들을 연결하는 시냅스(synapse)로 구성
50
50
- 인공 신경망(또는 단순히 신경망이라고 함)은 이러한 뉴런과 시냅스를 모델링
51
51
- 이 모델은 두 번째 AI 붐 중에 적극적으로 연구되었지만 레이어 매우 작았고, 이후 기술 발전으로 인해 대규모 네트워크로 확장되어 컴퓨터가 심층 학습을 실행할 수 있게됨
52
- <center ><img src =" https://mioscode.github.io/assets/images/dl1/neural_network.jpg " width =" 50 %" ></center >
52
+ <center ><img src =" https://mioscode.github.io/assets/images/dl1/neural_network.jpg " width =" 70 %" ></center >
53
53
54
54
# 2. Perceptron
55
55
@@ -59,32 +59,34 @@ comments: true
59
59
### Neuron과 Threshold
60
60
- 뉴런은 특정 자극(impulse) 이 있다면 그 자극이 어느 역치(threshold) 이상이여야 활성화(activation)
61
61
- 활동전위(action potential)가 축삭(axon)을 따라 내려가면서 세포막 안팎의 극성이 변화 -> 다른 뉴런에서 온 신호에 반응하여 막이 역치(threshold) 전위에 도달하면 Na+ 및 K+ 개폐 이온 채널이 여닫힘 -> 활동전위가 시작될 때 Na+ 채널이 열리고 Na+가 축삭 안으로 들어와 탈분극(Depolarization) -> 재분극은 K+ 채널이 열리고 K+가 축삭 밖으로 나갈 때 일어남 -> 채널의 개폐로 세포 안팎 극성이 변화 -> 신경 자극은 한 방향으로만 이동하여 축삭 말단(axon ending)에서 다른 뉴런으로 신호를 전달
62
- <center ><img src =" https://mioscode.github.io/assets/images/dl1/action_potential.gif " width =" 50 %" ></center >
63
- <center ><img src =" https://mioscode.github.io/assets/images/dl1/action_potential.png " width =" 50 %" ></center >
62
+ <center ><img src =" https://mioscode.github.io/assets/images/dl1/action_potential.gif " width =" 70 %" ></center >
63
+ <center ><img src =" https://mioscode.github.io/assets/images/dl1/action_potential.png " width =" 70 %" ></center >
64
64
65
65
### Perceptron과 $\theta$
66
66
- 뉴런을 모방함
67
- <center ><img src =" https://mioscode.github.io/assets/images/dl1/neural_network_perceptron.png " width =" 50 %" ></center >
67
+ <center ><img src =" https://mioscode.github.io/assets/images/dl1/neural_network_perceptron.png " width =" 70 %" ></center >
68
68
69
69
- 입력(input) 신호의 총합이 정해진 임계값($\theta$) 넘었을 때 $1$을 출력(output), 넘지 못하면 $0$ 또는 $-1$ 출력
70
70
- 각 입력신호에 고유한 weight 부여되며 기계학습은 이 weight(입력을 조절하니 매개변수로도 볼 수 있음)의 값을 정하는 작업
71
71
72
- <center ><img src =" https://mioscode.github.io/assets/images/dl1/perceptron_1.png " width =" 50 %" ></center >
73
- <c
8000
enter ><img src =" https://mioscode.github.io/assets/images/dl1/perceptron_2.png " width =" 50 %" ></center >
74
- <center ><img src =" https://mioscode.github.io/assets/images/dl1/perceptron_3.png " width =" 50 %" ></center >
75
- <center ><img src =" https://mioscode.github.io/assets/images/dl1/perceptron_4.png " width =" 50 %" ></center >
72
+ <center ><img src =" https://mioscode.github.io/assets/images/dl1/perceptron_1.png " width =" 70 %" ></center >
73
+ <center ><img src =" https://mioscode.github.io/assets/images/dl1/perceptron_2.png " width =" 70 %" ></center >
74
+ <center ><img src =" https://mioscode.github.io/assets/images/dl1/perceptron_3.png " width =" 70 %" ></center >
75
+ <center ><img src =" https://mioscode.github.io/assets/images/dl1/perceptron_4.png " width =" 70 %" ></center >
76
76
77
77
## 2.2. 학습 방법
78
78
1 . 처음에는 인간이 임의로 weight로 시작
79
79
2 . 머신이 학습 데이터를 퍼셉트론 모형에 입력하며 분류가 잘못됐을 때 weight를 개선 (인간이 문제 틀렸을 때 다시 푸는 것과 유사 -> 학습이라고 부름)
80
- <center ><img src =" https://mioscode.github.io/assets/images/dl1/machine_learning.jpg " width =" 50 %" ></center >
80
+ <center ><img src =" https://mioscode.github.io/assets/images/dl1/machine_learning.jpg " width =" 70 %" ></center >
81
81
82
82
## 2.3. 가중치(weight)와 편향(bias)
83
83
- 앞의 퍼셉트론 수식에서 나오는 세타$\theta$를 $-b$로 치환하여 좌변으로 넘기면 아래와 같이 되며 여기에서 $b$를 편향(bias)라고 할 수 있다.
84
+
84
85
$$ \begin{matrix}
85
86
b+w_1x_1+w_2x_2<0 \Rightarrow 0\\
86
87
b+w_1x_1+w_2x_2 \geqq 0 \Rightarrow 1
87
88
\end{matrix} $$
89
+
88
90
- 기계학습 분야에서는 모델이 학습 데이터에 과적합(overfitting)되는 것을 방지하는 것이 중요
89
91
- 과적합: 모델이 엄청 유연해서 학습 데이터는 귀신같이 잘 분류하지만, 다른 평가 데이터를 넣어봤을 때는 제대로 성능을 발휘하지 못하는 것을 말한다. 어느 데이터를 넣어도 일반적으로 잘 들어맞는 모델을 만드는 것이 중요하다.
90
92
- 편향이 높을 수록 그만큼 분류의 기준이 엄격하다는 것을 의미하며 모델이 간단해지는 경향이 있고 (변수가 적고 더 일반화 되는 경우) 오히려 과소적합(underfitting)의 위험이 발생하게 된다.
@@ -94,18 +96,28 @@ b+w_1x_1+w_2x_2 \geqq 0 \Rightarrow 1
94
96
- 퍼셉트론의 출력 값은 앞에서 말했듯이 1 또는 0(or -1)이기 때문에 학습 데이터가 선형적으로 분리될 수 있을 때 적합한 알고리즘
95
97
- 선형 분류는 평면 상에 선을 쫙 그어서 여기 넘으면 A, 못 넘으면 B 이런식으로 선을 기준으로 분류하는 것 의미
96
98
- 학습이 반복될수록 선 기울기 달라짐 (학습을 하면서 weight가 계속 조정됨)
97
- <center ><img src =" https://mioscode.github.io/assets/images/dl1/perceptron_example.png " width =" 50 %" ></center >
99
+ <center ><img src =" https://mioscode.github.io/assets/images/dl1/perceptron_example.png " width =" 70 %" ></center >
98
100
99
101
## 2.5. 퍼셉트론의 한계점
100
102
- AND와 OR과 같은 선형 데이터는 분류 가능하지만, XOR과 같은 형태의 비선형 데이터는 분류가 불가능하다
101
103
- AND 게이트: x1과 x2 중 모두(and) 1일때 1을 출력
104
+
102
105
| $x_1$| $x_2$| $y$|
103
106
| :-:| :-:| :-:|
104
107
| 0| 0| 0|
105
108
| 0| 1| 0|
106
109
| 1| 0| 0|
107
110
| 1| 1| 1|
111
+
112
+ > #### python numpy 패키지
113
+ > 1 . 숫자배열 연산을 위한 라이브러리입니다.
114
+ > 2 . numpy array는 파이썬 리스트보다 속도가 빠르며 리스트간 연산에 편의성을 제공합니다.
115
+ > 3 . sorting이나 indexing, intersection을 찾는 경우에도 속도가 빠릅니다.
116
+ > 4 . 평균, 중앙값, 최빈값, 사분위수, 분산, 표준편차를 찾는 경우에도 리스트보다 훨씬 코드가 간단하고 속도가 빠릅니다.
117
+
108
118
``` python
119
+ import numpy as np
120
+
109
121
def AND (x1 , x2 ):
110
122
x = np.array([x1,x2])
111
123
w = np.array([0.5 ,0.5 ])
@@ -121,17 +133,19 @@ b+w_1x_1+w_2x_2 \geqq 0 \Rightarrow 1
121
133
print (x[0 ]," , " ,x[1 ]," ==> " ,AND(x[0 ],x[1 ]), sep = ' ' )
122
134
```
123
135
- OR 게이트: x1과 x2 중 하나만(or ) 1 이면 1 을 출력
136
+
124
137
| $ x_1$ | $ x_2$ | $ y$ |
125
138
| :- :| :- :| :- :|
126
139
| 0 | 0 | 0 |
127
140
| 0 | 1 | 1 |
128
141
| 1 | 0 | 1 |
129
142
| 1 | 1 | 1 |
143
+
130
144
```python
131
145
def OR (x1 ,x2 ):
132
146
x = np.array([x1,x2])
133
- w = np.array([0.5 , 0.5 ])
134
- theta = 0
147
+ w = np.array([? , ? ])
148
+ theta = ?
135
149
if np.sum(w* x) <= theta:
136
150
return 0
137
151
else :
@@ -142,17 +156,19 @@ b+w_1x_1+w_2x_2 \geqq 0 \Rightarrow 1
142
156
print (x[0 ]," , " ,x[1 ]," ==> " ,OR(x[0 ],x[1 ]), sep = ' ' )
143
157
```
144
158
- NAND 게이트: x1과 x2 중 하나만(or ) 0 이면 1 을 출력
159
+
145
160
| $ x_1$ | $ x_2$ | $ y$ |
146
161
| :- :| :- :| :- :|
147
162
| 0 | 0 | 1 |
148
163
| 0 | 1 | 1 |
149
164
| 1 | 0 | 1 |
150
165
| 1 | 1 | 0 |
166
+
151
167
```python
152
168
def NAND (x1 ,x2 ):
153
169
x = np.array([x1,x2])
154
- w = np.array([- 0.5 , - 0.5 ])
155
- theta = - 0.7
170
+ w = np.array([? , ? ])
171
+ theta = ?
156
172
if np.sum(w* x) <= theta:
157
173
return 0
158
174
else :
@@ -163,26 +179,28 @@ b+w_1x_1+w_2x_2 \geqq 0 \Rightarrow 1
163
179
print (x[0 ]," , " ,x[1 ]," ==> " ,OR(x[0 ],x[1 ]), sep = ' ' )
164
180
```
165
181
- XOR 게이트: x1과 x2 중 어느 한쪽이 1 일 때만 1 을 출력 (둘다 1 이면 0 출력)
182
+
166
183
| $ x_1$ | $ x_2$ | $ y$ |
167
184
| :- :| :- :| :- :|
168
185
| 0 | 0 | 0 |
169
186
| 0 | 1 | 1 |
170
187
| 1 | 0 | 1 |
171
188
| 1 | 1 | 0 |
172
- < center>< img src= " https://mioscode.github.io/assets/images/dl1/xor.gif" width= " 50%" >< / center>
189
+
190
+ < center>< img src= " https://mioscode.github.io/assets/images/dl1/xor.gif" width= " 100%" >< / center>
173
191
174
192
- 한계점이 밝혀지면서 한동안 소외 받았고, 퍼셉트론을 제시한 로젠블랫은 자살 같은 사고로 세상을 떠났고 시간이 흐른 뒤에야 그의 업적이 재조명 받았다.
175
193
176
- # # 2.6. 다층 퍼셉트론을 통한 한계 극복
194
+ # # 2.6. 다층 퍼셉트론(Multi Layer Perceptron)을 통한 한계 극복
177
195
- 단층 퍼셉트론: AND , OR , NAND 게이트와 같이 입력층에 가중치를 곱해 바로 출력되는 퍼셉트론
178
196
< center>< img src= " https://mioscode.github.io/assets/images/dl1/perceptron.png" width= " 50%" >< / center>
179
197
180
198
- 다층 퍼셉트론: 퍼셉트론을 층으로 쌓은 것으로,입력층과 출력층 사이 은닉층이 존재하는 것
181
199
< center>< img src= " https://mioscode.github.io/assets/images/dl1/multi_perceptron.png" width= " 50%" >< / center>
182
200
183
201
- 위와 같은 다층 퍼셉트론(AND , OR , NAND 를 조합)으로 XOR 게이트를 구현할 수 있음
184
- < center>< img src= " https://mioscode.github.io/assets/images/dl1/XOR_1.png" width= " 50 %" >< / center>
185
- < center>< img src= " https://mioscode.github.io/assets/images/dl1/gate.png" width= " 50 %" >< / center>
202
+ < center>< img src= " https://mioscode.github.io/assets/images/dl1/XOR_1.png" width= " 70 %" >< / center>
203
+ < center>< img src= " https://mioscode.github.io/assets/images/dl1/gate.png" width= " 70 %" >< / center>
186
204
187
205
| $ x_1$ | $ x_2$ | $ s_1$ | $ s_2$ | $ y$ |
188
206
| :- :| :- :| :- :| :- :| :- :|
@@ -200,9 +218,9 @@ for x in inputData:
200
218
print (x[0 ]," , " ,x[1 ]," ==> " ,XOR(x[0 ],x[1 ]), sep = ' ' )
201
219
```
202
220
203
- ## Reference
204
- https://journal.jp.fujitsu.com/en/2016/02/09/01/
205
- https://sacko.tistory.com/10?category=632408
206
- https://www.neuraldesigner.com/blog/perceptron-the-main-component-of-neural-networks
207
- https://github.com/chaitjo/Perceptron
208
- http://ecee.colorado.edu/~ecen4831/lectures/NNet3.html
221
+ # Reference
222
+ - https://journal.jp.fujitsu.com/en/2016/02/09/01/
223
+ - https://sacko.tistory.com/10?category=632408
224
+ - https://www.neuraldesigner.com/blog/perceptron-the-main-component-of-neural-networks
225
+ - https://github.com/chaitjo/Perceptron
226
+ - http://ecee.colorado.edu/~ecen4831/lectures/NNet3.html
0 commit comments