Gradient Descent

Gradient를 이용해서 loss landscape의 minima point 를 찾아가는 기술.

Vanilla GD


while True:
	weights_grad = evalutae_gradient(loss_func, data, weights)
	weights += - step_size * weights_grad # perform parameter update

Algorithm

  1. Intialize , pick the lr
  2. 모든 데이터 포인트 에 대해, do:
  3. Forward-pass and, get the
  4. Backward-pass, to get gradient
  5. Update gradients:
  6. Validation Error가 커지면, step2로 가져 again. otherwise stop.

Remark

  • 일반적으로, 모델 파라미터 수는 Million 단위. 요즘은 Billion, Trillion 까지도 가지만,
  • 또한 데이터 포인트 수 역시, Million 단위, 마찬가지로 더 크기도 하다.
  • 때문에 computing power가 많이 요구됨.

Choosing a lr(Learning Rate)


Multi column

small lr

  • slow progress

large lr divergence

Gradient Clipping

Steep Cliff: how?


  • 이러한 경우처럼, loss curvature 혹은 landscape이 steep 하면, GD는 튕겨버릴(catapult) 수 있는데,
  • 이럴 때 Gradient clipping을 사용한다. (a common heuristics)

Gradient Clipping

easy하다. 그냥 일정 threshold 잡고 max 사용하면 된다.
Gradient exploding을 막아주는 역할.

원본 링크