-
Multiclass Classification | Neural Network Advanced OptimizationMachine Learning/Stanford ML Specialization 2024. 4. 2. 08:54
Gradient Descent
Gradient descent(그레디언트 디센트, 경사하강법)은 ML에서 널리 사용되는 최적화 알고리즘인데, Cost Function을 최소화 하는데 사용할 수 있는 다른 최적화 알고리즘도 있다. 우리가 그동안 봐왔던 Gradient descent보다 훨씬 더 나은 방법이다. 경사하강법보다 빠르게 트레이닝 할 수 있는 방법이 어떤게 있는지 알아보자.
Analytics Vidhya Gradient Descent 에서는, 어떤 지점에서 시작해서, 학습률 알파를 잘 조정해서, 위의 공식처럼, 알맞은 w값을 찾아나가게 된다. 그런데, 만약 알파값이 너무 작으면, 모델을 트레이닝 하는데 너무 오래 걸리고, 만약 너무 높으면, 알맞은 값을 찾지 못할 수 있다.
The Adam Algorithm
Adam은 Adaptive Moment Estimation을 의미한다. 이 adam은 각 weight마다 다른 학습률 alpha를 사용한다. 하지만, 같은 direction으로 욺직이는것 같다면, 해당 alpha를 키워서 더 빨리 가보도록 하는것이다. 반대로, 파라미터가 앞뒤로 진동한다면, 알파값을 줄이게 된다.
geeksforgeeks 그러면 코드에서 Adam을 사용해 모델을 컴파일 한다면? 아래처럼 코드를 써주면 된다.
model = Sequential([ tf.keras.layers.Dense(units=25, activation='sigmoid'), tf.keras.layers.Dense(units=15, activation='sigmoid'), tf.keras.layers.Dense(units=10, activation='linear') ]) model.compile( optimizer=tf.keras.optimizers.Adam(learning_rate=le-3), loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logistics=True)) model.fit(X, Y, epoches=100)
위 예제에서 Adam의 기본 알파를 10^-3, 즉 0.001로 지정해서 시작하지만, 중간에 이 알파값은 변경될 수 있다.
Reference
고급 학습 알고리즘
머신러닝 전문 과정의 두 번째 과정에서는 다음을 학습합니다: - 다중 클래스 분류를 수행하기 위해 텐서플로로 신경망 구축 및 훈련 - 모델이 실제 세계의 데이터와 작업에 일반화되도록 머신
www.coursera.org
Gradient Descent Algorithm: How does it Work in Machine Learning?
Gradient descent is a popular machine learning algorithm but can appear tricky for newcomers. Here's an intuition behind it.
www.analyticsvidhya.com
https://www.geeksforgeeks.org/adam-adaptive-moment-estimation-optimization-ml/
ML | ADAM (Adaptive Moment Estimation) Optimization - GeeksforGeeks
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
www.geeksforgeeks.org
'Machine Learning > Stanford ML Specialization' 카테고리의 다른 글
Model Selection and Evaluation (1) 2024.04.27 Multiclass Classification | Neural Network Additional Layer Types (0) 2024.04.02 Multiclass Classification | Advanced Learning Algorithm (0) 2024.03.24 Activation Functions | Advanced Learning Algorithm (0) 2024.03.24 TensorFlow Training Details | Advanced Learning Algorithm (0) 2024.02.11