SlideShare a Scribd company logo
1 of 12
Explanation on TensorFlow Example
- MNIST for ML Beginners -
Hong-Bae Kim
Korea Aerospace Research Institute
x_image
(28x28)
Reshape
28x28  784x1 vector
.
.
.
10 digits
Networks Architecture
.
.
W, bx y=softmax(Wx+b)
Classifier Nets
Very simple Classier Nets
MNIST For ML Beginners
• Machine Learning 입문자를 위한 손글씨 숫자 분류기 만들기
• MNIST는 간단한 이미지의 집합으로 아래와 같은 손으로 적은 숫자로 구성
• 간단한 Classifier Nets를 구성하고 작동원리를 이해
• Softmax Regression으로 숫자를 추정
 Define phase : Computation result is not determined
 Define data and model
 Construct learning model
 Define cost function and optimizer
 Run phase : can get a computation result
in the case of putting model into session
 Execute computation
 Learning process using optimizer
To execute the graph,
Needs to connect with Core module
Real computation is performed in Core module
Computation process consists of two phases
• Tensorflow의 라이브러리를 불러옴.
>>> import tensorflow as tf
• MNIST 데이터 다운로드
>>> import input_data
>>> mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
mnist.tran:training 데이터 55,000
mnist.test:test 데이터 10,000
mnist.validation:validation 데이터 5,000
>>> sess = tf.InteractiveSession()
데이터 불러오기
Define Phase
mnist.trans.xs, mnist.trans.ys 를 아래와 같이 정의
각이미지의 출력정답데이터
28pixel×28pixel의 이미지를 28×28=784의 벡터로 변환
벡터의 요소는 0(백)~1(흑)의 실수
각이미지의 입력벡터 데이터
1
0
0
0
0
0
0
0
0
0
“0”일 경우
0
0
0
0
0
1
0
0
0
0
“5”일 경우
Define Phase
변수의 정의
• 입력 이미지데이터(28x28=784)의 텐서 사이즈를 정의
>>> x = tf.placeholder(tf.float32, [None, 784])
• Weight 사이즈를 정의하고 초기화
>>> W = tf.Variable(tf.zeros([784, 10]))
• Bias의 사이즈를 정의하고 초기화
>>> b = tf.Variable(tf.zeros([10]))
• 출력의 정의
>>> y = tf.nn.softmax(tf.matmul(x, W) + b)
• 출력 정답데이터(10x1)의 텐서 사이즈를 정의
>>> y_ = tf.placeholder(tf.float32, [None, 10])
Define Phase
Softmax Regressions
입력데이터(x)가 Nets의 연산과정(Wx+b)을 거친 후 10개의 숫자 중
어느 것에 해당하는지에 대한 확률 계산
𝑝 𝑦(𝑖) = 0 𝑥(𝑖); 𝑤
⋮
𝑝 𝑦(𝑖) = 9 𝑥(𝑖); 𝑤
=
1
𝑗=1
10
e
𝑤j
T 𝑥(𝑖)
ew1
T 𝑥(𝑖)
⋮
ew10
T 𝑥(𝑖)
y=softmax(Wx+b) 0.85
0.05
0.05
0.01
0.01
0.01
0.01
0.02
0.01
0.03
“0”일 경우
0.01
0.05
0.05
0.01
0.01
0.90
0.01
0.02
0.01
0.03
“5”일 경우
∑=1 ∑=1
Define Phase
손실함수(Loss Function)의 정의
>>> cross_entropy = -tf.reduce_sum(y_*tf.log(y))
For 𝑦_𝑖 = 1 𝑐𝑎𝑠𝑒 J(w)=log𝑦𝑖
𝑦𝑖
1
J(w)
As 𝑦𝑖 approaches to 1,
J(w) becomes 0
J(w)=-∑𝑦_𝑖•log𝑦𝑖
y : 분류기에서 추정한 확률값
y_ : 정답
Define Phase
>>> train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy)
Backpropagation Algorithm의 정의
cross_entropy를 최소화하도록 GradientDescentOptimizer를 사용하여
훈련한다.
Define Phase
Learning rate
Run phase
# 변수 초기화
>>> init = tf.initialize_all_variables()
>>> sess = tf.Session()
>>> sess.run(init)
훈련실시
>>> for i in range(1000):
... batch_xs, batch_ys = mnist.train.next_batch(100)
... sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys})
i<1000 ?
랜덤하게 100개의 이미지 데이터
를 선택하여 입력을 batch_xs,
출력정답을 batch_ys로 지정
훈련 실시
i=i+1
yes
No
end
Run phase
훈련된 분류기의 검증
• 정답의 정의
>>> correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))
Returns the index with the largest value across dimensions of a tensor
Return “1” if argmax(y, 1) = argmax(y_, 1), otherwise return “0”
• 정확도의 정의
>>> accuracy = tf.reduce_mean(tf.cast(correct_prediction, 'float'))
Casts a tensor to “float”
calculate mean value
• 정답율을 계산하여 표시
>>> print(accuracy.eval({x: mnist.test.images, y_: mnist.test.labels}))

More Related Content

What's hot

Anomaly Detection with GANs
Anomaly Detection with GANsAnomaly Detection with GANs
Anomaly Detection with GANs홍배 김
 
Learning to remember rare events
Learning to remember rare eventsLearning to remember rare events
Learning to remember rare events홍배 김
 
딥러닝 제대로시작하기 Ch04
딥러닝 제대로시작하기 Ch04딥러닝 제대로시작하기 Ch04
딥러닝 제대로시작하기 Ch04HyeonSeok Choi
 
내가 이해하는 SVM(왜, 어떻게를 중심으로)
내가 이해하는 SVM(왜, 어떻게를 중심으로)내가 이해하는 SVM(왜, 어떻게를 중심으로)
내가 이해하는 SVM(왜, 어떻게를 중심으로)SANG WON PARK
 
Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Cap...
Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Cap...Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Cap...
Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Cap...홍배 김
 
Rnn개념정리
Rnn개념정리Rnn개념정리
Rnn개념정리종현 최
 
밑바닥부터시작하는딥러닝 Ch05
밑바닥부터시작하는딥러닝 Ch05밑바닥부터시작하는딥러닝 Ch05
밑바닥부터시작하는딥러닝 Ch05HyeonSeok Choi
 
4.convolutional neural networks
4.convolutional neural networks4.convolutional neural networks
4.convolutional neural networksHaesun Park
 
집단지성 프로그래밍 07-고급 분류 기법-커널 기법과 svm-01
집단지성 프로그래밍 07-고급 분류 기법-커널 기법과 svm-01집단지성 프로그래밍 07-고급 분류 기법-커널 기법과 svm-01
집단지성 프로그래밍 07-고급 분류 기법-커널 기법과 svm-01Kwang Woo NAM
 
해커에게 전해들은 머신러닝 #3
해커에게 전해들은 머신러닝 #3해커에게 전해들은 머신러닝 #3
해커에게 전해들은 머신러닝 #3Haesun Park
 
keras 빨리 훑어보기(intro)
keras 빨리 훑어보기(intro)keras 빨리 훑어보기(intro)
keras 빨리 훑어보기(intro)beom kyun choi
 
03.12 cnn backpropagation
03.12 cnn backpropagation03.12 cnn backpropagation
03.12 cnn backpropagationDea-hwan Ki
 
Reinforcement learning v0.5
Reinforcement learning v0.5Reinforcement learning v0.5
Reinforcement learning v0.5SANG WON PARK
 
해커에게 전해들은 머신러닝 #1
해커에게 전해들은 머신러닝 #1해커에게 전해들은 머신러닝 #1
해커에게 전해들은 머신러닝 #1Haesun Park
 
Support Vector Machines
Support Vector MachinesSupport Vector Machines
Support Vector MachinesDaegeun Lee
 
딥러닝의 기본
딥러닝의 기본딥러닝의 기본
딥러닝의 기본deepseaswjh
 
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 4: Neural Networks I
Lecture 4: Neural Networks ILecture 4: Neural Networks I
Lecture 4: Neural Networks ISang Jun Lee
 

What's hot (20)

Anomaly Detection with GANs
Anomaly Detection with GANsAnomaly Detection with GANs
Anomaly Detection with GANs
 
Learning to remember rare events
Learning to remember rare eventsLearning to remember rare events
Learning to remember rare events
 
딥러닝 제대로시작하기 Ch04
딥러닝 제대로시작하기 Ch04딥러닝 제대로시작하기 Ch04
딥러닝 제대로시작하기 Ch04
 
내가 이해하는 SVM(왜, 어떻게를 중심으로)
내가 이해하는 SVM(왜, 어떻게를 중심으로)내가 이해하는 SVM(왜, 어떻게를 중심으로)
내가 이해하는 SVM(왜, 어떻게를 중심으로)
 
Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Cap...
Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Cap...Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Cap...
Knowing when to look : Adaptive Attention via A Visual Sentinel for Image Cap...
 
Rnn개념정리
Rnn개념정리Rnn개념정리
Rnn개념정리
 
밑바닥부터시작하는딥러닝 Ch05
밑바닥부터시작하는딥러닝 Ch05밑바닥부터시작하는딥러닝 Ch05
밑바닥부터시작하는딥러닝 Ch05
 
4.convolutional neural networks
4.convolutional neural networks4.convolutional neural networks
4.convolutional neural networks
 
집단지성 프로그래밍 07-고급 분류 기법-커널 기법과 svm-01
집단지성 프로그래밍 07-고급 분류 기법-커널 기법과 svm-01집단지성 프로그래밍 07-고급 분류 기법-커널 기법과 svm-01
집단지성 프로그래밍 07-고급 분류 기법-커널 기법과 svm-01
 
Gmm to vgmm
Gmm to vgmmGmm to vgmm
Gmm to vgmm
 
해커에게 전해들은 머신러닝 #3
해커에게 전해들은 머신러닝 #3해커에게 전해들은 머신러닝 #3
해커에게 전해들은 머신러닝 #3
 
keras 빨리 훑어보기(intro)
keras 빨리 훑어보기(intro)keras 빨리 훑어보기(intro)
keras 빨리 훑어보기(intro)
 
Digit recognizer
Digit recognizerDigit recognizer
Digit recognizer
 
03.12 cnn backpropagation
03.12 cnn backpropagation03.12 cnn backpropagation
03.12 cnn backpropagation
 
Reinforcement learning v0.5
Reinforcement learning v0.5Reinforcement learning v0.5
Reinforcement learning v0.5
 
해커에게 전해들은 머신러닝 #1
해커에게 전해들은 머신러닝 #1해커에게 전해들은 머신러닝 #1
해커에게 전해들은 머신러닝 #1
 
Support Vector Machines
Support Vector MachinesSupport Vector Machines
Support Vector Machines
 
딥러닝의 기본
딥러닝의 기본딥러닝의 기본
딥러닝의 기본
 
2.linear regression and logistic regression
2.linear regression and logistic regression2.linear regression and logistic regression
2.linear regression and logistic regression
 
Lecture 4: Neural Networks I
Lecture 4: Neural Networks ILecture 4: Neural Networks I
Lecture 4: Neural Networks I
 

Viewers also liked

Meta-Learning with Memory Augmented Neural Networks
Meta-Learning with Memory Augmented Neural NetworksMeta-Learning with Memory Augmented Neural Networks
Meta-Learning with Memory Augmented Neural Networks홍배 김
 
Binarized CNN on FPGA
Binarized CNN on FPGABinarized CNN on FPGA
Binarized CNN on FPGA홍배 김
 
Convolution 종류 설명
Convolution 종류 설명Convolution 종류 설명
Convolution 종류 설명홍배 김
 
Normalization 방법
Normalization 방법 Normalization 방법
Normalization 방법 홍배 김
 
Explanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expertExplanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expert홍배 김
 
InfoGAN: Interpretable Representation Learning by Information Maximizing Gene...
InfoGAN: Interpretable Representation Learning by Information Maximizing Gene...InfoGAN: Interpretable Representation Learning by Information Maximizing Gene...
InfoGAN: Interpretable Representation Learning by Information Maximizing Gene...홍배 김
 
Visualizing data using t-SNE
Visualizing data using t-SNEVisualizing data using t-SNE
Visualizing data using t-SNE홍배 김
 
Learning by association
Learning by associationLearning by association
Learning by association홍배 김
 
Single Shot MultiBox Detector와 Recurrent Instance Segmentation
Single Shot MultiBox Detector와 Recurrent Instance SegmentationSingle Shot MultiBox Detector와 Recurrent Instance Segmentation
Single Shot MultiBox Detector와 Recurrent Instance Segmentation홍배 김
 
머신러닝의 자연어 처리기술(I)
머신러닝의 자연어 처리기술(I)머신러닝의 자연어 처리기술(I)
머신러닝의 자연어 처리기술(I)홍배 김
 
딥러닝을 이용한 자연어처리의 연구동향
딥러닝을 이용한 자연어처리의 연구동향딥러닝을 이용한 자연어처리의 연구동향
딥러닝을 이용한 자연어처리의 연구동향홍배 김
 
Q Learning과 CNN을 이용한 Object Localization
Q Learning과 CNN을 이용한 Object LocalizationQ Learning과 CNN을 이용한 Object Localization
Q Learning과 CNN을 이용한 Object Localization홍배 김
 

Viewers also liked (12)

Meta-Learning with Memory Augmented Neural Networks
Meta-Learning with Memory Augmented Neural NetworksMeta-Learning with Memory Augmented Neural Networks
Meta-Learning with Memory Augmented Neural Networks
 
Binarized CNN on FPGA
Binarized CNN on FPGABinarized CNN on FPGA
Binarized CNN on FPGA
 
Convolution 종류 설명
Convolution 종류 설명Convolution 종류 설명
Convolution 종류 설명
 
Normalization 방법
Normalization 방법 Normalization 방법
Normalization 방법
 
Explanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expertExplanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expert
 
InfoGAN: Interpretable Representation Learning by Information Maximizing Gene...
InfoGAN: Interpretable Representation Learning by Information Maximizing Gene...InfoGAN: Interpretable Representation Learning by Information Maximizing Gene...
InfoGAN: Interpretable Representation Learning by Information Maximizing Gene...
 
Visualizing data using t-SNE
Visualizing data using t-SNEVisualizing data using t-SNE
Visualizing data using t-SNE
 
Learning by association
Learning by associationLearning by association
Learning by association
 
Single Shot MultiBox Detector와 Recurrent Instance Segmentation
Single Shot MultiBox Detector와 Recurrent Instance SegmentationSingle Shot MultiBox Detector와 Recurrent Instance Segmentation
Single Shot MultiBox Detector와 Recurrent Instance Segmentation
 
머신러닝의 자연어 처리기술(I)
머신러닝의 자연어 처리기술(I)머신러닝의 자연어 처리기술(I)
머신러닝의 자연어 처리기술(I)
 
딥러닝을 이용한 자연어처리의 연구동향
딥러닝을 이용한 자연어처리의 연구동향딥러닝을 이용한 자연어처리의 연구동향
딥러닝을 이용한 자연어처리의 연구동향
 
Q Learning과 CNN을 이용한 Object Localization
Q Learning과 CNN을 이용한 Object LocalizationQ Learning과 CNN을 이용한 Object Localization
Q Learning과 CNN을 이용한 Object Localization
 

Similar to MNIST for ML beginners

딥러닝을 위한 Tensor flow(skt academy)
딥러닝을 위한 Tensor flow(skt academy)딥러닝을 위한 Tensor flow(skt academy)
딥러닝을 위한 Tensor flow(skt academy)Tae Young Lee
 
Effective modern cpp item14
Effective modern cpp item14Effective modern cpp item14
Effective modern cpp item14진화 손
 
1.자료구조와 알고리즘(강의자료)
1.자료구조와 알고리즘(강의자료)1.자료구조와 알고리즘(강의자료)
1.자료구조와 알고리즘(강의자료)fmbvbfhs
 
Ch.5 Deep Learning
Ch.5 Deep LearningCh.5 Deep Learning
Ch.5 Deep LearningPartPrime
 
Tensorflow
TensorflowTensorflow
Tensorflowchs71
 
Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho
Tfk 6618 tensor_flow로얼굴인식구현_r10_mariochoTfk 6618 tensor_flow로얼굴인식구현_r10_mariocho
Tfk 6618 tensor_flow로얼굴인식구현_r10_mariochoMario Cho
 
Deep Learning Into Advance - 1. Image, ConvNet
Deep Learning Into Advance - 1. Image, ConvNetDeep Learning Into Advance - 1. Image, ConvNet
Deep Learning Into Advance - 1. Image, ConvNetHyojun Kim
 
Cnn 발표자료
Cnn 발표자료Cnn 발표자료
Cnn 발표자료종현 최
 
Deep learningwithkeras ch3_1
Deep learningwithkeras ch3_1Deep learningwithkeras ch3_1
Deep learningwithkeras ch3_1PartPrime
 
Adversarial Attack in Neural Machine Translation
Adversarial Attack in Neural Machine TranslationAdversarial Attack in Neural Machine Translation
Adversarial Attack in Neural Machine TranslationHyunKyu Jeon
 
파이썬 데이터과학 레벨2 - 데이터 시각화와 실전 데이터분석, 그리고 머신러닝 입문 (2020년 이태영)
파이썬 데이터과학 레벨2 - 데이터 시각화와 실전 데이터분석, 그리고 머신러닝 입문 (2020년 이태영)파이썬 데이터과학 레벨2 - 데이터 시각화와 실전 데이터분석, 그리고 머신러닝 입문 (2020년 이태영)
파이썬 데이터과학 레벨2 - 데이터 시각화와 실전 데이터분석, 그리고 머신러닝 입문 (2020년 이태영)Tae Young Lee
 
3ds maxscript 튜토리얼_20151206_서진택
3ds maxscript 튜토리얼_20151206_서진택3ds maxscript 튜토리얼_20151206_서진택
3ds maxscript 튜토리얼_20151206_서진택JinTaek Seo
 
Chapter8 touch 6 10 group11
Chapter8 touch 6 10 group11Chapter8 touch 6 10 group11
Chapter8 touch 6 10 group11Hyun Wong Choi
 
3.neural networks
3.neural networks3.neural networks
3.neural networksHaesun Park
 
[0312 조진현] good bye dx9
[0312 조진현] good bye dx9[0312 조진현] good bye dx9
[0312 조진현] good bye dx9진현 조
 

Similar to MNIST for ML beginners (20)

딥러닝을 위한 Tensor flow(skt academy)
딥러닝을 위한 Tensor flow(skt academy)딥러닝을 위한 Tensor flow(skt academy)
딥러닝을 위한 Tensor flow(skt academy)
 
Effective modern cpp item14
Effective modern cpp item14Effective modern cpp item14
Effective modern cpp item14
 
1.자료구조와 알고리즘(강의자료)
1.자료구조와 알고리즘(강의자료)1.자료구조와 알고리즘(강의자료)
1.자료구조와 알고리즘(강의자료)
 
Ch.5 Deep Learning
Ch.5 Deep LearningCh.5 Deep Learning
Ch.5 Deep Learning
 
Tensorflow
TensorflowTensorflow
Tensorflow
 
1강 - pytorch와 tensor.pptx
1강 - pytorch와 tensor.pptx1강 - pytorch와 tensor.pptx
1강 - pytorch와 tensor.pptx
 
Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho
Tfk 6618 tensor_flow로얼굴인식구현_r10_mariochoTfk 6618 tensor_flow로얼굴인식구현_r10_mariocho
Tfk 6618 tensor_flow로얼굴인식구현_r10_mariocho
 
R_datamining
R_dataminingR_datamining
R_datamining
 
Deep Learning Into Advance - 1. Image, ConvNet
Deep Learning Into Advance - 1. Image, ConvNetDeep Learning Into Advance - 1. Image, ConvNet
Deep Learning Into Advance - 1. Image, ConvNet
 
Cnn 발표자료
Cnn 발표자료Cnn 발표자료
Cnn 발표자료
 
Deep learningwithkeras ch3_1
Deep learningwithkeras ch3_1Deep learningwithkeras ch3_1
Deep learningwithkeras ch3_1
 
Adversarial Attack in Neural Machine Translation
Adversarial Attack in Neural Machine TranslationAdversarial Attack in Neural Machine Translation
Adversarial Attack in Neural Machine Translation
 
파이썬 데이터과학 레벨2 - 데이터 시각화와 실전 데이터분석, 그리고 머신러닝 입문 (2020년 이태영)
파이썬 데이터과학 레벨2 - 데이터 시각화와 실전 데이터분석, 그리고 머신러닝 입문 (2020년 이태영)파이썬 데이터과학 레벨2 - 데이터 시각화와 실전 데이터분석, 그리고 머신러닝 입문 (2020년 이태영)
파이썬 데이터과학 레벨2 - 데이터 시각화와 실전 데이터분석, 그리고 머신러닝 입문 (2020년 이태영)
 
3ds maxscript 튜토리얼_20151206_서진택
3ds maxscript 튜토리얼_20151206_서진택3ds maxscript 튜토리얼_20151206_서진택
3ds maxscript 튜토리얼_20151206_서진택
 
R.T.Bach
R.T.BachR.T.Bach
R.T.Bach
 
Chapter8 touch 6 10 group11
Chapter8 touch 6 10 group11Chapter8 touch 6 10 group11
Chapter8 touch 6 10 group11
 
3.neural networks
3.neural networks3.neural networks
3.neural networks
 
[0312 조진현] good bye dx9
[0312 조진현] good bye dx9[0312 조진현] good bye dx9
[0312 조진현] good bye dx9
 
Naive ML Overview
Naive ML OverviewNaive ML Overview
Naive ML Overview
 
LeNet & GoogLeNet
LeNet & GoogLeNetLeNet & GoogLeNet
LeNet & GoogLeNet
 

More from 홍배 김

Automatic Gain Tuning based on Gaussian Process Global Optimization (= Bayesi...
Automatic Gain Tuning based on Gaussian Process Global Optimization (= Bayesi...Automatic Gain Tuning based on Gaussian Process Global Optimization (= Bayesi...
Automatic Gain Tuning based on Gaussian Process Global Optimization (= Bayesi...홍배 김
 
Gaussian processing
Gaussian processingGaussian processing
Gaussian processing홍배 김
 
Lecture Summary : Camera Projection
Lecture Summary : Camera Projection Lecture Summary : Camera Projection
Lecture Summary : Camera Projection 홍배 김
 
Learning agile and dynamic motor skills for legged robots
Learning agile and dynamic motor skills for legged robotsLearning agile and dynamic motor skills for legged robots
Learning agile and dynamic motor skills for legged robots홍배 김
 
Robotics of Quadruped Robot
Robotics of Quadruped RobotRobotics of Quadruped Robot
Robotics of Quadruped Robot홍배 김
 
Basics of Robotics
Basics of RoboticsBasics of Robotics
Basics of Robotics홍배 김
 
Convolutional neural networks 이론과 응용
Convolutional neural networks 이론과 응용Convolutional neural networks 이론과 응용
Convolutional neural networks 이론과 응용홍배 김
 
Anomaly detection using deep one class classifier
Anomaly detection using deep one class classifierAnomaly detection using deep one class classifier
Anomaly detection using deep one class classifier홍배 김
 
Optimal real-time landing using DNN
Optimal real-time landing using DNNOptimal real-time landing using DNN
Optimal real-time landing using DNN홍배 김
 
The world of loss function
The world of loss functionThe world of loss function
The world of loss function홍배 김
 
Machine learning applications in aerospace domain
Machine learning applications in aerospace domainMachine learning applications in aerospace domain
Machine learning applications in aerospace domain홍배 김
 
Anomaly Detection and Localization Using GAN and One-Class Classifier
Anomaly Detection and Localization  Using GAN and One-Class ClassifierAnomaly Detection and Localization  Using GAN and One-Class Classifier
Anomaly Detection and Localization Using GAN and One-Class Classifier홍배 김
 
ARCHITECTURAL CONDITIONING FOR DISENTANGLEMENT OF OBJECT IDENTITY AND POSTURE...
ARCHITECTURAL CONDITIONING FOR DISENTANGLEMENT OF OBJECT IDENTITY AND POSTURE...ARCHITECTURAL CONDITIONING FOR DISENTANGLEMENT OF OBJECT IDENTITY AND POSTURE...
ARCHITECTURAL CONDITIONING FOR DISENTANGLEMENT OF OBJECT IDENTITY AND POSTURE...홍배 김
 
Brief intro : Invariance and Equivariance
Brief intro : Invariance and EquivarianceBrief intro : Invariance and Equivariance
Brief intro : Invariance and Equivariance홍배 김
 

More from 홍배 김 (14)

Automatic Gain Tuning based on Gaussian Process Global Optimization (= Bayesi...
Automatic Gain Tuning based on Gaussian Process Global Optimization (= Bayesi...Automatic Gain Tuning based on Gaussian Process Global Optimization (= Bayesi...
Automatic Gain Tuning based on Gaussian Process Global Optimization (= Bayesi...
 
Gaussian processing
Gaussian processingGaussian processing
Gaussian processing
 
Lecture Summary : Camera Projection
Lecture Summary : Camera Projection Lecture Summary : Camera Projection
Lecture Summary : Camera Projection
 
Learning agile and dynamic motor skills for legged robots
Learning agile and dynamic motor skills for legged robotsLearning agile and dynamic motor skills for legged robots
Learning agile and dynamic motor skills for legged robots
 
Robotics of Quadruped Robot
Robotics of Quadruped RobotRobotics of Quadruped Robot
Robotics of Quadruped Robot
 
Basics of Robotics
Basics of RoboticsBasics of Robotics
Basics of Robotics
 
Convolutional neural networks 이론과 응용
Convolutional neural networks 이론과 응용Convolutional neural networks 이론과 응용
Convolutional neural networks 이론과 응용
 
Anomaly detection using deep one class classifier
Anomaly detection using deep one class classifierAnomaly detection using deep one class classifier
Anomaly detection using deep one class classifier
 
Optimal real-time landing using DNN
Optimal real-time landing using DNNOptimal real-time landing using DNN
Optimal real-time landing using DNN
 
The world of loss function
The world of loss functionThe world of loss function
The world of loss function
 
Machine learning applications in aerospace domain
Machine learning applications in aerospace domainMachine learning applications in aerospace domain
Machine learning applications in aerospace domain
 
Anomaly Detection and Localization Using GAN and One-Class Classifier
Anomaly Detection and Localization  Using GAN and One-Class ClassifierAnomaly Detection and Localization  Using GAN and One-Class Classifier
Anomaly Detection and Localization Using GAN and One-Class Classifier
 
ARCHITECTURAL CONDITIONING FOR DISENTANGLEMENT OF OBJECT IDENTITY AND POSTURE...
ARCHITECTURAL CONDITIONING FOR DISENTANGLEMENT OF OBJECT IDENTITY AND POSTURE...ARCHITECTURAL CONDITIONING FOR DISENTANGLEMENT OF OBJECT IDENTITY AND POSTURE...
ARCHITECTURAL CONDITIONING FOR DISENTANGLEMENT OF OBJECT IDENTITY AND POSTURE...
 
Brief intro : Invariance and Equivariance
Brief intro : Invariance and EquivarianceBrief intro : Invariance and Equivariance
Brief intro : Invariance and Equivariance
 

MNIST for ML beginners

  • 1. Explanation on TensorFlow Example - MNIST for ML Beginners - Hong-Bae Kim Korea Aerospace Research Institute
  • 2. x_image (28x28) Reshape 28x28  784x1 vector . . . 10 digits Networks Architecture . . W, bx y=softmax(Wx+b) Classifier Nets Very simple Classier Nets
  • 3. MNIST For ML Beginners • Machine Learning 입문자를 위한 손글씨 숫자 분류기 만들기 • MNIST는 간단한 이미지의 집합으로 아래와 같은 손으로 적은 숫자로 구성 • 간단한 Classifier Nets를 구성하고 작동원리를 이해 • Softmax Regression으로 숫자를 추정
  • 4.  Define phase : Computation result is not determined  Define data and model  Construct learning model  Define cost function and optimizer  Run phase : can get a computation result in the case of putting model into session  Execute computation  Learning process using optimizer To execute the graph, Needs to connect with Core module Real computation is performed in Core module Computation process consists of two phases
  • 5. • Tensorflow의 라이브러리를 불러옴. >>> import tensorflow as tf • MNIST 데이터 다운로드 >>> import input_data >>> mnist = input_data.read_data_sets('MNIST_data', one_hot=True) mnist.tran:training 데이터 55,000 mnist.test:test 데이터 10,000 mnist.validation:validation 데이터 5,000 >>> sess = tf.InteractiveSession() 데이터 불러오기 Define Phase
  • 6. mnist.trans.xs, mnist.trans.ys 를 아래와 같이 정의 각이미지의 출력정답데이터 28pixel×28pixel의 이미지를 28×28=784의 벡터로 변환 벡터의 요소는 0(백)~1(흑)의 실수 각이미지의 입력벡터 데이터 1 0 0 0 0 0 0 0 0 0 “0”일 경우 0 0 0 0 0 1 0 0 0 0 “5”일 경우 Define Phase
  • 7. 변수의 정의 • 입력 이미지데이터(28x28=784)의 텐서 사이즈를 정의 >>> x = tf.placeholder(tf.float32, [None, 784]) • Weight 사이즈를 정의하고 초기화 >>> W = tf.Variable(tf.zeros([784, 10])) • Bias의 사이즈를 정의하고 초기화 >>> b = tf.Variable(tf.zeros([10])) • 출력의 정의 >>> y = tf.nn.softmax(tf.matmul(x, W) + b) • 출력 정답데이터(10x1)의 텐서 사이즈를 정의 >>> y_ = tf.placeholder(tf.float32, [None, 10]) Define Phase
  • 8. Softmax Regressions 입력데이터(x)가 Nets의 연산과정(Wx+b)을 거친 후 10개의 숫자 중 어느 것에 해당하는지에 대한 확률 계산 𝑝 𝑦(𝑖) = 0 𝑥(𝑖); 𝑤 ⋮ 𝑝 𝑦(𝑖) = 9 𝑥(𝑖); 𝑤 = 1 𝑗=1 10 e 𝑤j T 𝑥(𝑖) ew1 T 𝑥(𝑖) ⋮ ew10 T 𝑥(𝑖) y=softmax(Wx+b) 0.85 0.05 0.05 0.01 0.01 0.01 0.01 0.02 0.01 0.03 “0”일 경우 0.01 0.05 0.05 0.01 0.01 0.90 0.01 0.02 0.01 0.03 “5”일 경우 ∑=1 ∑=1 Define Phase
  • 9. 손실함수(Loss Function)의 정의 >>> cross_entropy = -tf.reduce_sum(y_*tf.log(y)) For 𝑦_𝑖 = 1 𝑐𝑎𝑠𝑒 J(w)=log𝑦𝑖 𝑦𝑖 1 J(w) As 𝑦𝑖 approaches to 1, J(w) becomes 0 J(w)=-∑𝑦_𝑖•log𝑦𝑖 y : 분류기에서 추정한 확률값 y_ : 정답 Define Phase
  • 10. >>> train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy) Backpropagation Algorithm의 정의 cross_entropy를 최소화하도록 GradientDescentOptimizer를 사용하여 훈련한다. Define Phase Learning rate
  • 11. Run phase # 변수 초기화 >>> init = tf.initialize_all_variables() >>> sess = tf.Session() >>> sess.run(init) 훈련실시 >>> for i in range(1000): ... batch_xs, batch_ys = mnist.train.next_batch(100) ... sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys}) i<1000 ? 랜덤하게 100개의 이미지 데이터 를 선택하여 입력을 batch_xs, 출력정답을 batch_ys로 지정 훈련 실시 i=i+1 yes No end
  • 12. Run phase 훈련된 분류기의 검증 • 정답의 정의 >>> correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1)) Returns the index with the largest value across dimensions of a tensor Return “1” if argmax(y, 1) = argmax(y_, 1), otherwise return “0” • 정확도의 정의 >>> accuracy = tf.reduce_mean(tf.cast(correct_prediction, 'float')) Casts a tensor to “float” calculate mean value • 정답율을 계산하여 표시 >>> print(accuracy.eval({x: mnist.test.images, y_: mnist.test.labels}))