-
[모두를 위한 딥러닝] 6. Multi-Class Classification - SoftmaxAI/모두를 위한 딥러닝 2020. 12. 1. 03:35
# 다중 클래스 분류 (Multi-Class Classification)
앞선 로지스틱 회귀에서는 두 가지 선택지만 결정했다. 만약 세 가지 이상의 클래스를 두고 결정해야 하는 상황이라면 다중 클래스 분류(Multi-Class Classification)를 한다. 위와 같이 시간과 출석 여부라는 두 가지 변수에 대하여 A, B, C 세 가지 성적을 매기는 상황을 가정해보자. 성적 분포의 그래프는 오른쪽 그래프와 같다.
성적이 표현된 그래프를 로지스틱 회귀를 사용한다고 생각하고 A에 대해, B에 대해, C에 대해 각각 이진 분류한다면 위와 같이 3가지 선을 그을 수 있다. A인지 아닌지, B인지 아닌지, C인지 아닌지를 구별하는 세 가지 선을 그은 것이다.
이 3가지 식을 행렬로 표현하면 왼쪽 그림과 같다. 그리고 계산의 편의를 위해 이 식들을 또 하나의 행렬로 통합하면 오른쪽 그림과 같아진다. 오른쪽 그림의 계산식의 3가지 출력이 각각 A, B, C에 대한 H(x) 값이 된다.
A, B, C에 대한 각각의 예측값이 0~1 범위에 있게 하고 모두 합해 1이 나오게 한다면 편리한 계산을 할 수 있다. 이를 위해 위 그림과 같은 Softmax 함수를 사용한다. Softmax 함수를 사용하면 A, B, C에 대한 세 가지 예측값을 확률로서 사용할 수 있게 된다.
Softmax로 도출된 각각의 확률은 One-Hot Encoding을 통해 1 혹은 0으로 분류되고 각각의 예측값이 결론적으로 가리키는 것이 A인지 B인지 C인지를 확인할 수 있게 된다.
※ Softmax의 Cost 함수
본 포스팅은 김성훈 교수님의 강의
'모두를 위한 딥러닝'을 학습하고 정리한 내용을 담고 있습니다.
'AI > 모두를 위한 딥러닝' 카테고리의 다른 글
[모두를 위한 딥러닝] 9. 딥러닝으로 XOR 문제 풀기 (0) 2020.12.02 [모두를 위한 딥러닝] 7. Learning rate, Overfitting and Regularization (0) 2020.12.01 [모두를 위한 딥러닝] 5. Logistic Regression (0) 2020.11.25 [모두를 위한 딥러닝] 4. multi-variable linear regression (0) 2020.11.25 [모두를 위한 딥러닝] 2. Linear Regression (0) 2020.11.19