SlideShare a Scribd company logo
1 of 41
Machine/Deep Learning
with Theano
Softmax classification : Multinomial classification
Application & Tips : Learning rate, data preprocessing, overfitting
Deep Neural Nets for Everyone
Multinomial Classification
Softmax classification
Logistic Regression
𝐻𝐿(𝑋) = 𝑊𝑋
𝐻𝐿 𝑋 = 𝑍
𝑔(𝑍) =
1
1 + 𝑒−𝑍
𝐻 𝑅 𝑋 = 𝑔(𝐻𝐿(𝑋))
𝑋
𝑊
𝑍 𝑌
𝑌 : Prediction ( 0 ~ 1 )
𝑌 : Real Value ( 0 or 1 )
Binomial Classification
왼쪽의 그림은 원 일까?
yes/no
Binomial Classification
𝑥1 ⇒ 모서리의 경향성
𝑥2 ⇒ 직선의 경향성
𝑥1
𝑥2
원
𝑋
𝑊
𝑍 𝑌
다각형
Multinomial Classification
왼쪽의 그림은 A/B/C 중 무엇일까?
𝑥1
𝑥2
Multinomial Classification
𝑥1
𝑥2
Multinomial Classification
𝑋
𝑊
𝑍 𝑌
𝑥1
𝑥2
Multinomial Classification
𝑋
𝑊
𝑍 𝑌
𝑥1
𝑥2
Multinomial Classification
𝑋
𝑊
𝑍 𝑌
𝑥1
𝑥2
Multinomial Classification
𝑋
𝑊
𝑍 𝑌
𝑋
𝑊
𝑍 𝑌
𝑋
𝑊
𝑍 𝑌
Multinomial Classification
𝑋
𝑊
𝑍
𝑤1 𝑤2 𝑤3
𝑥1
𝑥2
𝑥3
= 𝑤1 𝑥1 + 𝑤2 𝑥2 + 𝑤3 𝑥3
Multinomial Classification
𝑋
𝑊
𝑍
𝑤 𝐴1 𝑤 𝐴2 𝑤 𝐴3
𝑥1
𝑥2
𝑥3
= 𝑤 𝐴1 𝑥1 + 𝑤 𝐴2 𝑥2 + 𝑤 𝐴3 𝑥3
𝑋
𝑊
𝑍
𝑤 𝐵1 𝑤 𝐵2 𝑤 𝐵3
𝑥1
𝑥2
𝑥3
= 𝑤 𝐵1 𝑥1 + 𝑤 𝐵2 𝑥2 + 𝑤 𝐵3 𝑥3
𝑋
𝑊
𝑍
𝑤 𝐶1 𝑤 𝐶2 𝑤 𝐶3
𝑥1
𝑥2
𝑥3
= 𝑤 𝐶1 𝑥1 + 𝑤 𝐶2 𝑥2 + 𝑤 𝐶3 𝑥3
Multinomial Classification
𝑋
𝑊
𝑍
𝑤 𝐴1 𝑥1 + 𝑤 𝐴2 𝑥2 + 𝑤 𝐴3 𝑥3
𝑤 𝐵1 𝑥1 + 𝑤 𝐵2 𝑥2 + 𝑤 𝐵3 𝑥3
𝑤 𝐶1 𝑥1 + 𝑤 𝐶2 𝑥2 + 𝑤 𝐶3 𝑥3
𝑋
𝑊
𝑍
𝑥1
𝑥2
𝑥3
=
𝑋
𝑊
𝑍
𝑤 𝐴1 𝑤 𝐴2 𝑤 𝐴3
𝑤 𝐵1 𝑤 𝐵2 𝑤 𝐵3
𝑤 𝐶1 𝑤 𝐶2 𝑤 𝐶3
𝐻𝐴(𝑋)
𝐻 𝐵(𝑋)
𝐻 𝐶(𝑋)
=
Multinomial Classification
𝐻𝐴(𝑋)
𝐻 𝐵(𝑋)
𝐻 𝐶(𝑋)
150
5
−0.1
example
=
Multinomial Classification : Softmax Function
Score Probability
𝑯 𝑨 𝑿 = 𝒁 𝑨
𝑯 𝑩 𝑿 = 𝒁 𝑩
𝑯 𝑪 𝑿 = 𝒁 𝑪
𝒀 𝑨
𝒀 𝑩
𝒀 𝑪
𝒔𝒐𝒇𝒕𝒎𝒂𝒙(𝒁𝒊)
=
𝒆 𝒁 𝒊
𝒊 𝒆 𝒁 𝒊
(2) 𝒊 𝒀𝒊 = 𝟏(1) 𝟎 ≤ 𝒀𝒊 ≤ 𝟏
Multinomial Classification
𝑋
𝑊𝐴
𝑍 𝐴
𝑋
𝑊𝐵
𝑍 𝐵
𝑋
𝑊𝐶
𝑍 𝐶
softmax hot encoding
(find maximum)
1.0
0.0
0.0
𝑌𝐵
𝑌𝑐
𝑌𝐴
0.8
0.15
0.05
Cost Function
Cross Entropy Function
Entropy Function
𝐻 𝑝 = − 𝑝(𝑥) log 𝑝(𝑥)
• 확률 분포 p 에 담긴 불확실성을 나타내는 지표
• 이 값이 클 수록 일정한 방향성과 규칙성이 없는 chaos
• p라는 대상을 표현하기위해 필요한 정보량(bit)
Cross Entropy Function
𝐻 𝑝, 𝑞 = − 𝑝(𝑥) log 𝑞(𝑥)
• 두 확률 분포 p, q 사이에 존재하는 정보량을 계산하는 방법
• p->q로 정보를 바꾸기 위해 필요한 정보량(bit)
Cross Entropy Cost Function
𝑋
𝑊𝐴
𝑍 𝐴
𝑋
𝑊𝐵
𝑍 𝐵
𝑋
𝑊𝐶
𝑍 𝐶
𝑌𝐴
𝑌𝐵
𝑌𝑐
𝑌 : Prediction ( 0 ~ 1 )
𝑌 : Real Value ( 0 or 1 )
𝐷 𝑌𝑖, 𝑌𝑖 = − 𝑌𝑖 log 𝑌𝑖
Cross Entropy Cost Function
𝑌𝐴
𝑌𝐵
𝑌𝐶
=
1
0
0
𝑌𝐴
𝑌𝐵
𝑌𝐶
=
1
0
0
−
1
0
0
∙ log
1
0
0
= −
1
0
0
0
∞
∞
=
0
0
0
= 0
𝐷 𝑌𝑖, 𝑌𝑖 = − 𝑌𝑖 log 𝑌𝑖
Cross Entropy Cost Function
𝐷 𝑌𝑖, 𝑌 𝑖 = − 𝑌𝑖 log 𝑌𝑖
𝑌𝐴
𝑌𝐵
𝑌𝐶
=
1
0
0
𝑌𝐴
𝑌𝐵
𝑌𝐶
=
0
1
0
−
0
1
0
∙ log
1
0
0
= −
1
0
0
0
∞
∞
=
0
−∞
0
= −∞
Logistic Cost VS Cross Entropy
binomial classification 의 경우
각각 오직 2가지 경우의 Real
Data와 H(x) 값이 나올 수 있다.
0
1
1
0
위 행렬은 다음과 같이 표현 할 수 있다.
𝐻(𝑥)
1 − 𝐻(𝑥)
𝐻 𝑥 , 𝑦
0
1
𝑦
1 − 𝑦
Logistic Cost VS Cross Entropy
Cross Entropy Cost Function에
대입하면
𝐻 𝐻(𝑥), 𝑦 = −
𝑦
1 − 𝑦 ∙ log
𝐻(𝑥)
1 − 𝐻(𝑥)
= −
𝑦log 𝐻 𝑥
1 − 𝑦 log(1 − 𝐻 𝑥 )
= −𝑦 log 𝐻 𝑋 − (1 − 𝑦)log(1 − 𝐻 𝑥 )
= 𝐶(𝐻 𝑥 , 𝑦)
Cross Entropy Cost Function
𝐿 =
1
𝑁
𝑛
𝐷 𝑛 𝑌, 𝑌 = −
1
𝑁
𝑌𝑖log 𝑌𝑖
N 개의 training set 에 대한 Cost들의 합
Application & Tips
Learning Rate
Data Preprocessing
Overshooting
Gradient Descent Function
𝑊 = 𝑊 − 𝛼
𝜕
𝜕𝑊
𝐶𝑜𝑠𝑡(𝑊)
Learning Rate
Learning rate : Overshooting
𝐿(𝑊)
𝑊
Learning rate : Too small
𝐿(𝑊)
𝑊
Data Preprocessing
𝐿(𝑊)
𝑊 𝑤1
𝑤2
Data Preprocessing
𝑤1
𝑤2
𝑊 = 𝑊 − 𝛼
𝜕
𝜕𝑊
𝐶𝑜𝑠𝑡(𝑊)
𝛼 가 변하면서 각 weight 값들에 미치는 영향이
다를 때 적절한 Learning rate을 찾기가 힘들어진
다.
Data Preprocessing : Standardization
𝑤𝑖′ =
𝑤𝑖 − 𝜇𝑖
𝜎𝑖
𝜇𝑖 ∶ 𝑤의 평균
𝜎𝑖 ∶ 𝑤의 표준편차
Overfitting
• training data에 과도하게 최적화 되는 현상
• real data에 대해선 잘 동작하지 않는다.
Overfitting
𝑥2
원
𝑥1
𝑥2
원
𝑥1
Overfitting
• 많은 양의 training data로 학습 시킨다.
• feature(𝑥𝑖)의 개수를 줄인다.
• Regularization
Solution:
Overfitting : Regularization
𝐿 =
1
𝑁
𝑛
𝐷 𝑛 𝑌, 𝑌 + λ 𝑊2
• weight가 너무 큰 값을 가지지 않도록 한다. => Cost 함수가 굴곡이 심하지 않도록
조정한다.
Regularization Strength
Overfitting : Regularization
𝐿 =
1
𝑁
𝑛
𝐷 𝑛 𝑌, 𝑌 + λ 𝑊2
Regularization Strength
Application & Tips
Learning and Test data sets
Training, validation and test sets
• training data에 대해서는 이미 정답을 memorize 한 상태이기 때문에
실제 real data에 잘 작동 하는지 확인을 할 수 없다. => Test data 필
요!
• 학습된 machine에 대해서 적절한 learning rate와 regularization
strengt를 찾기 위한 validation 작업이 있어야 한다. => Validation
data 필요!
Online Learning
Data
Model
• 너무 많은 양의 데이터
가 있을 때, 분할하여
나누어 학습시킨다.
• Data가 지속적으로 유
입 되는 경우 사용되기
도 한다.

More Related Content

Similar to Multinomial classification and application of ML

Neural network (perceptron)
Neural network (perceptron)Neural network (perceptron)
Neural network (perceptron)Jeonghun Yoon
 
04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )Jeonghun Yoon
 
03. linear regression
03. linear regression03. linear regression
03. linear regressionJeonghun Yoon
 
RLCode와 A3C 쉽고 깊게 이해하기
RLCode와 A3C 쉽고 깊게 이해하기RLCode와 A3C 쉽고 깊게 이해하기
RLCode와 A3C 쉽고 깊게 이해하기Woong won Lee
 
Rnn개념정리
Rnn개념정리Rnn개념정리
Rnn개념정리종현 최
 
Dsh data sensitive hashing for high dimensional k-nn search
Dsh  data sensitive hashing for high dimensional k-nn searchDsh  data sensitive hashing for high dimensional k-nn search
Dsh data sensitive hashing for high dimensional k-nn searchWooSung Choi
 
Lecture 2: Supervised Learning
Lecture 2: Supervised LearningLecture 2: Supervised Learning
Lecture 2: Supervised LearningSang Jun Lee
 
02.09 naive bayesian classifier
02.09 naive bayesian classifier02.09 naive bayesian classifier
02.09 naive bayesian classifierDea-hwan Ki
 
Linear regression
Linear regressionLinear regression
Linear regression전 희천
 
Probability with MLE, MAP
Probability with MLE, MAPProbability with MLE, MAP
Probability with MLE, MAPJunho Lee
 
Variational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial ModelVariational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial ModelSEMINARGROOT
 
2.linear regression and logistic regression
2.linear regression and logistic regression2.linear regression and logistic regression
2.linear regression and logistic regressionHaesun Park
 
Lecture 3: Unsupervised Learning
Lecture 3: Unsupervised LearningLecture 3: Unsupervised Learning
Lecture 3: Unsupervised LearningSang Jun Lee
 
Auto-Encoders and Variational Auto-Encoders
Auto-Encoders and Variational Auto-EncodersAuto-Encoders and Variational Auto-Encoders
Auto-Encoders and Variational Auto-EncodersJinho Lee
 
Chapter 19 Variational Inference
Chapter 19 Variational InferenceChapter 19 Variational Inference
Chapter 19 Variational InferenceKyeongUkJang
 
파이썬과 케라스로 배우는 강화학습 저자특강
파이썬과 케라스로 배우는 강화학습 저자특강파이썬과 케라스로 배우는 강화학습 저자특강
파이썬과 케라스로 배우는 강화학습 저자특강Woong won Lee
 
Lecture 4: Neural Networks I
Lecture 4: Neural Networks ILecture 4: Neural Networks I
Lecture 4: Neural Networks ISang Jun Lee
 
[Probability for machine learning]
[Probability for machine learning][Probability for machine learning]
[Probability for machine learning]강민국 강민국
 

Similar to Multinomial classification and application of ML (20)

Neural network (perceptron)
Neural network (perceptron)Neural network (perceptron)
Neural network (perceptron)
 
04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )
 
03. linear regression
03. linear regression03. linear regression
03. linear regression
 
RLCode와 A3C 쉽고 깊게 이해하기
RLCode와 A3C 쉽고 깊게 이해하기RLCode와 A3C 쉽고 깊게 이해하기
RLCode와 A3C 쉽고 깊게 이해하기
 
Rnn개념정리
Rnn개념정리Rnn개념정리
Rnn개념정리
 
Dsh data sensitive hashing for high dimensional k-nn search
Dsh  data sensitive hashing for high dimensional k-nn searchDsh  data sensitive hashing for high dimensional k-nn search
Dsh data sensitive hashing for high dimensional k-nn search
 
Lecture 2: Supervised Learning
Lecture 2: Supervised LearningLecture 2: Supervised Learning
Lecture 2: Supervised Learning
 
02.09 naive bayesian classifier
02.09 naive bayesian classifier02.09 naive bayesian classifier
02.09 naive bayesian classifier
 
Linear regression
Linear regressionLinear regression
Linear regression
 
Probability with MLE, MAP
Probability with MLE, MAPProbability with MLE, MAP
Probability with MLE, MAP
 
Variational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial ModelVariational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial Model
 
2.linear regression and logistic regression
2.linear regression and logistic regression2.linear regression and logistic regression
2.linear regression and logistic regression
 
Lecture 3: Unsupervised Learning
Lecture 3: Unsupervised LearningLecture 3: Unsupervised Learning
Lecture 3: Unsupervised Learning
 
Auto-Encoders and Variational Auto-Encoders
Auto-Encoders and Variational Auto-EncodersAuto-Encoders and Variational Auto-Encoders
Auto-Encoders and Variational Auto-Encoders
 
Vae
VaeVae
Vae
 
Chapter 19 Variational Inference
Chapter 19 Variational InferenceChapter 19 Variational Inference
Chapter 19 Variational Inference
 
파이썬과 케라스로 배우는 강화학습 저자특강
파이썬과 케라스로 배우는 강화학습 저자특강파이썬과 케라스로 배우는 강화학습 저자특강
파이썬과 케라스로 배우는 강화학습 저자특강
 
Lecture 4: Neural Networks I
Lecture 4: Neural Networks ILecture 4: Neural Networks I
Lecture 4: Neural Networks I
 
Super resolution
Super resolutionSuper resolution
Super resolution
 
[Probability for machine learning]
[Probability for machine learning][Probability for machine learning]
[Probability for machine learning]
 

Recently uploaded

파일 업로드(Kitworks Team Study 유현주 발표자료 240510)
파일 업로드(Kitworks Team Study 유현주 발표자료 240510)파일 업로드(Kitworks Team Study 유현주 발표자료 240510)
파일 업로드(Kitworks Team Study 유현주 발표자료 240510)Wonjun Hwang
 
오픈소스 위험 관리 및 공급망 보안 솔루션 'Checkmarx SCA' 소개자료
오픈소스 위험 관리 및 공급망 보안 솔루션 'Checkmarx SCA' 소개자료오픈소스 위험 관리 및 공급망 보안 솔루션 'Checkmarx SCA' 소개자료
오픈소스 위험 관리 및 공급망 보안 솔루션 'Checkmarx SCA' 소개자료Softwide Security
 
클라우드 애플리케이션 보안 플랫폼 'Checkmarx One' 소개자료
클라우드 애플리케이션 보안 플랫폼 'Checkmarx One' 소개자료클라우드 애플리케이션 보안 플랫폼 'Checkmarx One' 소개자료
클라우드 애플리케이션 보안 플랫폼 'Checkmarx One' 소개자료Softwide Security
 
[OpenLAB] AWS reInvent를 통해 바라본 글로벌 Cloud 기술동향.pdf
[OpenLAB] AWS reInvent를 통해 바라본 글로벌 Cloud 기술동향.pdf[OpenLAB] AWS reInvent를 통해 바라본 글로벌 Cloud 기술동향.pdf
[OpenLAB] AWS reInvent를 통해 바라본 글로벌 Cloud 기술동향.pdfssuserf8b8bd1
 
Grid Layout (Kitworks Team Study 장현정 발표자료)
Grid Layout (Kitworks Team Study 장현정 발표자료)Grid Layout (Kitworks Team Study 장현정 발표자료)
Grid Layout (Kitworks Team Study 장현정 발표자료)Wonjun Hwang
 
도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'
도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'
도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'Hyundai Motor Group
 

Recently uploaded (6)

파일 업로드(Kitworks Team Study 유현주 발표자료 240510)
파일 업로드(Kitworks Team Study 유현주 발표자료 240510)파일 업로드(Kitworks Team Study 유현주 발표자료 240510)
파일 업로드(Kitworks Team Study 유현주 발표자료 240510)
 
오픈소스 위험 관리 및 공급망 보안 솔루션 'Checkmarx SCA' 소개자료
오픈소스 위험 관리 및 공급망 보안 솔루션 'Checkmarx SCA' 소개자료오픈소스 위험 관리 및 공급망 보안 솔루션 'Checkmarx SCA' 소개자료
오픈소스 위험 관리 및 공급망 보안 솔루션 'Checkmarx SCA' 소개자료
 
클라우드 애플리케이션 보안 플랫폼 'Checkmarx One' 소개자료
클라우드 애플리케이션 보안 플랫폼 'Checkmarx One' 소개자료클라우드 애플리케이션 보안 플랫폼 'Checkmarx One' 소개자료
클라우드 애플리케이션 보안 플랫폼 'Checkmarx One' 소개자료
 
[OpenLAB] AWS reInvent를 통해 바라본 글로벌 Cloud 기술동향.pdf
[OpenLAB] AWS reInvent를 통해 바라본 글로벌 Cloud 기술동향.pdf[OpenLAB] AWS reInvent를 통해 바라본 글로벌 Cloud 기술동향.pdf
[OpenLAB] AWS reInvent를 통해 바라본 글로벌 Cloud 기술동향.pdf
 
Grid Layout (Kitworks Team Study 장현정 발표자료)
Grid Layout (Kitworks Team Study 장현정 발표자료)Grid Layout (Kitworks Team Study 장현정 발표자료)
Grid Layout (Kitworks Team Study 장현정 발표자료)
 
도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'
도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'
도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'
 

Multinomial classification and application of ML

Editor's Notes

  1. 도박을 할 때 확률 값을 기반으로 값을 맞춘다고 하자 동전 던지기의 경우 H, T 0.5 0.5 이므로 확률 데이터를 기반으로 답을 맞추는 의미가 없다. => 엔트로피 1 특정 동전의 경우 H, T 0.8, 0.2 이라고 할 때 이 확률 데이터를 기반으로 H를 선택하면 답을 맞출 확률이 높아진다. => 엔트로피가 작아진다. 즉 모든 확률의 값이 똑같을 때 엔트로피는 가장 높고 특정 데이터에 확률이 치중 되어 있을 때 엔트로피는 작아진다.