Skip to content

Commit 5e8b7c0

Browse files
Add files via upload
1 parent 948de42 commit 5e8b7c0

File tree

1 file changed

+217
-0
lines changed

1 file changed

+217
-0
lines changed

CNN/CS231n 6강(혜주).md

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
# CS231n 6강(혜주)
2+
3+
다음은 스탠포드 대학 강의 [CS231n: Convolutional Neural Networks for Visual Recognition](http://cs231n.stanford.edu/) 을 요약한 것입니다.
4+
5+
6+
7+
6강의 내용을 도식화해서 정리하면 다음과 같습니다.
8+
9+
![cs231n_6_](https://user-images.githubusercontent.com/32008883/32380789-642cb69c-c0f4-11e7-8fa3-51a4d03ab504.JPG)
10+
11+
12+
13+
14+
15+
## 1. Activation Functions
16+
17+
### 1) Sigmoid function
18+
19+
![cs231n_6_1](https://user-images.githubusercontent.com/32008883/32380799-694b7d70-c0f4-11e7-9a20-f24213ac281e.JPG)
20+
21+
- 특징
22+
- output의 범위가 0과 1이 되게 한다.
23+
- neuron의 firing rate을 잘 나타낸다고 생각되어서 인기가 많았다.
24+
- 단점
25+
- 극단값들의 gradient는 결국 0이 되어 의미가 없어진다.
26+
- sigmoid의 output은 0이 중심이 되지 않는다. -> 항상 양수인 input이 들어오면 w에 대한 gradient는 모두 양수이거나 음수가 된다 -> w vector가 비효율적으로 찾아진다.
27+
- 함수에 exp()이 들어가서 computing이 비효율적이다.
28+
29+
30+
31+
### 2) ReLU function
32+
33+
![cs231n_6_6](https://user-images.githubusercontent.com/32008883/32381234-894a37a0-c0f5-11e7-9129-6cd0320e03a3.JPG)
34+
35+
**f(x) = max(0,x)**
36+
37+
38+
39+
- 특징
40+
- (+)부분에서 output 부분을 뭉개지 않는다.
41+
- exp()이 없어서 컴퓨팅적으로 효율적이다.
42+
- sigmoid나 tanh보다 빨리 converge한다.
43+
- sigmoid보다 neuron의 작용을 더 잘 반영한다.
44+
- 단점
45+
- 역시 0이 중심인 output은 아니다.
46+
- 0보다 작은 부분의 gradient는 0이 되어버린다.
47+
48+
49+
50+
ReLU를 보완한 Leaky ReLU, PReLU등이 있다.
51+
52+
실제적으로 ReLU를 사용하면 좋다. (단, learning rate설정 유의)
53+
54+
sigmoid는 별로 효과가 좋지 않다. 초반에 나온 것이라 사용되었던 거지 지금은 ReLU를 많이 쓴다고 한다.
55+
56+
57+
58+
59+
60+
## 2. Data Preprocessing
61+
62+
![cs231n_6_10](https://user-images.githubusercontent.com/32008883/32381233-890cea4e-c0f5-11e7-93b6-a1a2c9f00dd0.JPG)
63+
64+
데이터 전처리에 주로 zero-centering을 많이 사용한다. 이미지 처리에서는 normalization까지 하지는 않는다.
65+
66+
67+
68+
## 3. Weight Initialization
69+
70+
weight을 처음에 어떻게 시작하는지에 따라 학습 과정이 달라질 수 있으므로 weight initialization은 중요하다.
71+
72+
1) 작은 랜덤 숫자로 시작? **sd=0.01**
73+
74+
**W = 0.01* np.random.randn(D,H)**
75+
76+
작은 네트워크에서는 괜찮지만, 네트워크의 깊이가 깊어지면 분산이 0으로 가기 때문에, 아래와 같이 데이터들이 줄어든다. 즉, 모든 activiation이 0 이 되어버린다. 이에 따라 upstreaming gradient가 0이 된다.
77+
78+
79+
![cs231n_6_12](https://user-images.githubusercontent.com/32008883/32381720-bd26cc5e-c0f6-11e7-99b2-f131d5da11ed.JPG)
80+
81+
82+
83+
2) **sd=1로 설정하면?**
84+
85+
하단과 같이 모든 뉴런이 -1아니면 1이 되어버려 gradient는 모두 0 이 되어버린다.
86+
87+
88+
89+
90+
![cs231n_6_14](https://user-images.githubusercontent.com/32008883/32381722-bddd81d8-c0f6-11e7-8bf2-d26b8c0aff12.JPG)
91+
92+
93+
3) Xavier Initialization
94+
95+
``` W = np.random.randn(fan_in,fan_out) / np.sqrt(fan_in)```
96+
97+
적절한 initialization을 만들어주는 방법이다.
98+
99+
![cs231n_6_16](https://user-images.githubusercontent.com/32008883/32381951-5cf2ea06-c0f7-11e7-820a-a6104ddae04a.JPG)
100+
101+
그러나 ReLU에 사용하면 제대로 작동하지 않는다. 하단과 같이 보충한다.
102+
103+
` W = np.random.randn(fan_in,fan_out) / np.sqrt(fan_in/2)`
104+
105+
106+
107+
## 4. Batch Normalization
108+
109+
batch normalization은 batch의 dimension마다 unit gaussain activation을 만들어주는 과정이다.
110+
111+
112+
113+
![cs231n_6_19](https://user-images.githubusercontent.com/32008883/32381949-5c497f2a-c0f7-11e7-9da8-59cf46e6615f.JPG)
114+
![cs231n_6_20](https://user-images.githubusercontent.com/32008883/32381950-5ca33448-c0f7-11e7-8d36-eb489b7a3f02.JPG)
115+
116+
117+
118+
![cs231n_6_21](https://user-images.githubusercontent.com/32008883/32383005-214accb4-c0fa-11e7-9926-76e5b2d2c91a.JPG)
119+
120+
1. dimension에 따라 평균과 분산 계산
121+
2. 식에 따라 normalize
122+
123+
![cs231n_6_22](https://user-images.githubusercontent.com/32008883/32383006-217d1a70-c0fa-11e7-8b2a-ca25145dcb9d.JPG)
124+
125+
- 위치: FC layer 혹은 Convolutional layer 뒤, 그리고 nonlinearity function 앞.
126+
- normalize 한 것을 다시 되돌리기 위해 하단의 식을 사용한다.
127+
128+
![cs231n_6_23](https://user-images.githubusercontent.com/32008883/32382999-2089f6a6-c0fa-11e7-8c9f-d4a95967bd34.JPG)
129+
![cs231n_6_24](https://user-images.githubusercontent.com/32008883/32383002-20f0258e-c0fa-11e7-97a7-77e0c36f39a6.JPG)
130+
131+
- 특징
132+
- gradient flow 향상
133+
- 좀 더 높은 learning rate 가능하게 함
134+
- initialization에 대한 의존도를 줄인다
135+
136+
137+
138+
## 5. Babysitting Learning Process
139+
140+
학습 과정을 간단히 정리하면,
141+
142+
첫번째 step: 데이터 전처리
143+
144+
두번쨰 step: 구조를 선택한다.
145+
146+
147+
148+
![cs231n_6_25](https://user-images.githubusercontent.com/32008883/32383003-211e9522-c0fa-11e7-98d5-40138c179a2a.JPG)
149+
150+
- loss가 적절한지 확인하는 법
151+
- regularization term을 없앴다가 만든다. regularization term을 넣어서 loss가 올라가면 잘 된 거다.
152+
- loss가 줄어들지 않고 그대로? : learning rate너무 낮아
153+
- loss가 폭발적?: learning rate너무 높아
154+
- cross validating할 때 대충 [1e-3,..1e-5]면 적당하다고 한다.
155+
156+
157+
158+
![cs231n_6_26](https://user-images.githubusercontent.com/32008883/32383250-d9ed9d64-c0fa-11e7-8442-d76dac3b605e.JPG)
159+
![cs231n_6_27](https://user-images.githubusercontent.com/32008883/32383251-da189b9a-c0fa-11e7-8a65-559090a0649e.JPG)
160+
161+
162+
163+
- Cross-validation 전략(coarse -> fine)
164+
- 먼저 coarse하게 대충 어떻게 parameter들이 작동하는지 파악
165+
- 이후 fine 하게 parameter찾기
166+
167+
168+
169+
170+
![cs231n_6_32](https://user-images.githubusercontent.com/32008883/32383475-67c6a2c0-c0fb-11e7-80de-75631fcf102b.JPG)
171+
172+
173+
174+
![cs231n_6_33](https://user-images.githubusercontent.com/32008883/32383467-6655f346-c0fb-11e7-9e80-5a9b206e53b4.JPG)
175+
176+
177+
178+
- Random Search가 Grid Search보다 좋다.
179+
180+
![cs231n_6_34](https://user-images.githubusercontent.com/32008883/32383469-668ef088-c0fb-11e7-896b-1a6727578a51.JPG)
181+
182+
183+
184+
- learning rate말고도 network 구조, decay schedule, update type, regularization등 조정해야 할게 많다. 이에 따라 loss function의 작동이 달라지므로.
185+
186+
187+
188+
189+
190+
##6. Hyperparmeter Optimization
191+
192+
1) loss curve보기
193+
194+
good learning rate의 모양 잘 봐두자!
195+
196+
![cs231n_6_36](https://user-images.githubusercontent.com/32008883/32383637-de735684-c0fb-11e7-8d29-097b0695a987.JPG)
197+
198+
다음과 같은 형태의 loss curve하면 bad initialization을 의심해봐야 한다.
199+
200+
![cs231n_6_37](https://user-images.githubusercontent.com/32008883/32383640-dede0a92-c0fb-11e7-8803-38d430ca9165.JPG)
201+
202+
- train set accuracy vs. validation set accuracy
203+
- 큰 차이: overfitting문제
204+
- 차이 x : overfitting x
205+
206+
![cs231n_6_38](https://user-images.githubusercontent.com/32008883/32383632-ddb74ffc-c0fb-11e7-9f10-9f89e45011ce.JPG)
207+
208+
- weight의 update비율을 확인하고 조정하는 것도 좋은 방법!
209+
210+
![cs231n_6_39](https://user-images.githubusercontent.com/32008883/32383634-ddf1b336-c0fb-11e7-9597-286125e99976.JPG)
211+
212+
213+
214+
## + 강의자님의 요약..
215+
216+
![cs231n_6_40](https://user-images.githubusercontent.com/32008883/32383635-de2c10d0-c0fb-11e7-9a41-6f2c8b7c4ad9.JPG)
217+

0 commit comments

Comments
 (0)