###간단 코드
grad_squared = 0
while True:
dx = compute_gradient(x)
grad_squared += dx * dx
x -= learning_rate * dx / (np.sqrt(grad_squared) + 1e-7)
compute_gradient(x) ==> G_t += [g_t[0]^2, ...,g_t[d]^2]
np.sqrt(grad_squared)
@@@AdaGrad
grad_squared = 0
while True:
dx = compute_gradient(x)
grad_squared += dx * dx
x -= learning_rate * dx / (np.sqrt(grad_squared) + 1e-7)
@@@RMSProp
grad_squared = 0
while True:
dx = compute_gradient(x)
grad_squared += decay_rate * grad_squared + (1 - decay_rate) * dx * dx
x -= learning_rate * dx / (np.sqrt(grad_squared) + 1e-7)
@@@AdaGrad/RMSProp
first_moment = 0
second_moment = 0
while True:
dx = compute_gradient(x)
first_moment = beta1 * first_moment + (1 - beta1) *dx
second_moment = beta2 * second_monent + (1 -beta2) * dx * dx
x -= learning_rate * first_moment / (np.sqrt(grad_squared) + 1e-7)
@@@Adam(fullform)
first_moment = 0
second_moment = 0
while True:
dx = compute_gradient(x)
first_moment = beta1 * first_moment + (1 - beta1) *dx
second_moment = beta2 * second_monent + (1 -beta2) * dx * dx
first_unbias = first_moment / (1 - beta1 **t)
second_unbias = second_moment / (1 -beta2 **t)
x -= learning_rate * first_unbias / (np.sqrt(second_unbias) + 1e-7)
'K-MOOC > 머신러닝' 카테고리의 다른 글
6주차 API (0) | 2020.04.09 |
---|---|
5주차 점수 산출 (0) | 2020.04.02 |
3주차 Gradient descent, Coordinate descent (0) | 2020.03.24 |
2주차 선형대수 기본 개념 (0) | 2020.03.22 |
1주차 머신러닝 개요 및 케이스 스터디 (0) | 2020.03.20 |