728x90
반응형
SMALL
import numpy as np
def fn(x):
print(x/x.sum())
a = np.array([2.0,1.0,0.1])
fn(a)
[OUT]:
[0.64516129 0.32258065 0.03225806]
-> 전체 합에서 차지하는 비율
Softmax
def softmax(x):
e = np.exp(x)
print(e)
print( e/np.sum(e))
a = np.array([2.0,1.0,0.1])
softmax(a)
[OUT]:
[7.3890561 2.71828183 1.10517092]
[0.65900114 0.24243297 0.09856589]
-> e^x를 하여 확률이 높은곳에 가중치를 더 주는 형식
review
- 다중분류 시 사용되는 softmax
728x90
반응형
LIST
'코딩으로 익히는 Python > 모델링' 카테고리의 다른 글
[Python] 13. KNN분류 (0) | 2021.01.21 |
---|---|
[Python] 12. 다중분류 (0) | 2021.01.21 |
[Python] 10. confusion matrix : precision,recall,f1,ROC (2) | 2021.01.21 |
[Python] 9. Logistic Regression (로지스틱 회귀) (0) | 2021.01.20 |
[Python] 8. Sigmoid & Logistic (0) | 2021.01.20 |