기술(Tech, IT)/머신 러닝(Machine Learning)

[ML] Gradient Descent(경사하강법)

Daniel803 2023. 2. 25. 10:00

 IBM에서 이런 내용도 게재하는지 몰랐는데 Gradient Descent(경사하강법)에 대해 아래와 같이 설명하고 있다. 한국어론 경사하강법이라고 하지만 Gradient Descent라는 용어로 인지를 하고 있는 것이 여러 자료를 접할 때 더 편할 것으로 생각돼 영어와 한국어 모두 기억하는 것을 추천한다. 뿐만 아니라 Cost Function 혹은 대부분의 용어들은 영어로 함께 기억하는 것이 나을 것으로 생각한다.

: Gradient descent is an optimization algorithm which is commonly-used to train machine learning models and neural networks.  Training data helps these models learn over time, and the cost function within gradient descent specifically acts as a barometer, gauging its accuracy with each iteration of parameter updates. Until the function is close to or equal to zero, the model will continue to adjust its parameters to yield the smallest possible error. Once machine learning models are optimized for accuracy, they can be powerful tools for artificial intelligence (AI) and computer science applications.

: Gradent descent(경사하강법)은 Machine Learning(기계 학습) 모델과 Neural Networks(신경망)을 학습시킬 때 흔히 사용되는 최적화 알고리즘이다. 학습용 데이터는 이 모델들이 시간을 거듭하면서 학습할 수 있도록 도와주고 Gradient Descent의 Cost Function(비용 함수)는 특히 지표의 역할은 한다 Cost Function은 파라미터가 업데이트 되는 매 반복마다 정확도를 나타낸다. Cost Function이 0이 되거나 0에 가까워질 때까지, Machine Learning 모델과 Neural Networks는 파라미터를 조절해가며 가능한 가장 작은 에러를 산출해간다. Machine Learning 모델이 높은 정확도에 최적화되면, 이들은 AI나 Computer Science 앱의 강력한 도구가 될 수 있다.

 

 Cost Function에 대해 간단한 설명을 더하자면 x라는 input에 대한 실제 output인 y와 앞서 언급된 모델에 x를 input으로 넣었을 때 얻은 z의 차이를 결과로 뱉는 함수를 말한다. 즉, 우리가 만든 모델의 결과값과 실제값의 차이가 적을 수록 모델이 훌륭하다는 것을 의미하기에 0에 가까워지는 값을 찾는 것이다. 아래 그림은 Gradient Descent에 대한 이해를 도울 때 많이 등장한다.

 일단 개념은 위와 같지만 제대로 이해하기 위해선 수학적인 이해가 동반돼야한다. Gradient Descent를 도함수를 통한 편미분을 통해 각 좌표(포인트, 점)에의 기울기 값이 최종적으로 0으로 수렴되는 곳을 찾아간다. 

 Gradient Descent의 일반적인 식은 아래와 같다. 현재 좌표(x_i)와 현재 좌표에서 기울기(f(x_i))에 Leaning Late(학습률) a을 곱한 값을 빼 다음 좌표(x_(i+1))을 구한다. 이 구해지는 다음 좌표가 앞서 말한 parameter update, 즉 업데이트 된 파라미터고 이를 반복해 0에 가까운 지점을 찾아간다.

 Gradient Descent에는 여러 종류가 있는데 대표적으로 Batch Gradient Descent(배치 경사하강법), Stochastic Gradient Descent(확률적 경사하강법), Mini-batch Gradient Descent(미니 배치 경사하강법)이 있다. 참고로 일반 Gradient Descent는 Vanilla Gradient Descent라 부르기도 한다.

 

출처

- https://www.ibm.com/topics/gradient-descent

- https://www.javatpoint.com/gradient-descent-in-machine-learning