SlideShare a Scribd company logo
Machine Learning Workshop I
Image Classification
Tao Chen
taochen@qnap.com
關於講師
陳雲濤 Tao Chen
taochen@qnap.com
Software Engineer,
Data Intelligence & Application Div., QNAP
Experience on IoT with computer vision, image processing,
image classification, object detection & segmentation.
課前準備
● 本課程會實作一個客製化的照片分類模型
● 請大家準備兩種類別照片,每種至少 50 張以上,分別存放在兩個資料夾中
● 適合對象:
1. 未接觸過 Machine Learning 的開發者
2. 有使用ML相關經驗,想認識 Deep Learning 方法者
3. 有興趣的想實作自己照片分類器的 QNAPers
課程大綱
● Introduction to Machine Learning
● Neural Network
● Deep Neural Network (DNN)
● Convolutional Neural Network (CNN)
● Image Classification on Fashion MNIST Dataset
● Prepare Your Data for Image Classification
● Train Your Image Classification Model
Introduction to Machine Learning
Introduction to Machine Learning
● Traditional:
Data
Data
● Machine Learning:
Output
Machine Learning ≈ Looking for a Function
this is a cat
Training Testing
“cat”
“not a
cat”
You write the
program for learning
Ref: 出自台大電機系李宏毅老師 Machine Learning 課程投影片
Type of Machine Learning Task
● Classification → output class
● Regression → output value
“cat”
影像辨識
88.87mm
本月總降雨量預測
中央氣象局觀測資料
Goodness of Machine Learning Function
● Classification → output class
● Regression → output value
“cat”
88.87 mm中央氣象局觀測資料 87.00 mm
“cat”
Ground Truth
evaluate by accuracy
evaluate by MSE (mean
squared error)
Machine Learning Process
“cat”
Ref: 出自台大電機系李宏毅老師 Machine Learning 課程投影片
Performance Evaluation (Accuracy)
● 假設100個病患使用某模型做疾病檢測
○ 檢測有病為 Positive
○ 檢測沒病為 Negative
● 前提(病患之真實狀況)
○ 15 個病患有病
○ 85 的病患沒病
● 某模型之檢測結果
○ 20 個病患檢測有病 (其中只有 10 個病患真的有病,10 個誤判)
○ 80 個病患檢測沒病 (其中只有 75 個病患真的沒病,5 個誤判)
檢測有病 檢測沒病
真實有病 10 5
真實沒病 10 75
Accuracy: (10+75)/100 = 85%
Precision, Recall and F1-score
對的說成對的
錯的說成錯的
錯的說成對的
對的說成錯的
● 假設100個病患使用某模型做疾病檢測
○ 檢測有病為 Positive
○ 檢測沒病為 Negative
● 前提(病患之真實狀況)
○ 15 個病患有病
○ 85 的病患沒病
● 某模型之檢測結果
○ 20 個病患檢測有病 (其中只有 10 個病患真的有病,10 個誤判)
○ 80 個病患檢測沒病 (其中只有 75 個病患真的沒病,5 個誤判)
檢測有病 檢測沒病
真實有病 10 5
真實沒病 10 75
→ TP: 10, TN: 75, FP: 10, FN: 5
→ Precision: 10/(10+10)= 50%, Recall: 10/(10+5)= 66.66%
→ F1-score: 2*0.5*0.66/(0.5+0.66) = 57.14%
Accuracy: (10+75)/100 = 85%
Performance Evaluation (F1-score)
from:http://speech.ee.ntu.edu.tw/~tlkagk/courses/ML_2017_2/Lecture/introduction.pdf
NN = Neural Network
(one kind of ML function)
Neural Network
from cs231n:http://cs231n.stanford.edu/
Basic NN
input Activation
Function
bias
weight
z = input(s) * weight(s) + bias
from NTU ML course:https://www.youtube.com/watch?v=Dr-WRlEFefw
2
-3
0.5
0.5
0.6
0.5
0.1
0.6
0
0.3
0.6
0.4
0.15
0.2
0.1
0.5
Activation Function f :
0.4
0.5
f(-0.6)
f(0.3)
input
input
weight
bias
0.27
0.38
f(0.27)
f(0.38)
0.217
(output)
Basic NN
[ 2 ✕ 0.4 + (-3) ✕ 0.5 ] + 0.1 =
-0.6
[ 2 ✕ 0.6 + (-3) ✕ 0.5 ] + 0.6 =
0.3
from cs231n:http://cs231n.stanford.edu/
Activation Functions
2
-3
0.5
0.5
0.6
0.5
0.1
0.6
0
0.3
0.6
0.4
0.15
0.2
0.27
0.38
0.217
0.4
0.5
0.1
0.5
f(-0.6)
f(0.3)
f(0.27)
f(0.38)
0.3
Ground
Truth
Judge by Loss function
e.g. MSE
Loss value = MSE(0.217, 0.3) = 0.006889
Training NN
new
bias
new
bias
new
bias
new
bias
0.217
new
weight
0.3
Ground
Truth
Judge by Loss function
e.g. MSE
Loss value = MSE(0.217, 0.3) = 0.006889
Update Weights and Biases with Loss value
new
weight
new
weights
new
weights
Learn by
next data
Training NN
(By Backpropogation Algorithm)
2
-3
0.5
0.5
0.6
0.5
0.1
0.6
0
0.3
0.6
0.4
0.15
0.2
0.27
0.38
0.308
0.4
0.5
1
0.5
f(-0.6)
f(0.3)
f(0.27)
f(0.38) 0.71
2
0.1
Ground T.
0
1
Cross Entropy Loss
dog
cat
Sleep
Walk
with U
Basic NN (Classification)
from cs231n:http://cs231n.stanford.edu/
圖片出處:http://lucenaresearch.com/deep-neural-networks/
DNN = Deep Neural Network
Ref : https://achintavarna.wordpress.com/2017/11/17/keras-tutorial-for-beginners-a-simple-neural-network-to-identify-numbers-mnist-data/
…
0
0
0
0
0
0
0
0
1
0
count loss with Ground T.
Update Weights and Biases with Loss value
0.04
0.01
0.02
0.11
0.01
0.06
0.21
0.01
0.35
0.18
CNN = Convolutional Neural Network
Basic Architecture of CNN
Ref: 出自台大電機系李宏毅老師 Machine Learning 課程投影片
Convolution
Max Pooling
Flatten
特徵擷取
Feature Extraction
降維度
Reduce Resolution
將所有擷取到的特徵攤
平
→ 降為一維向量
to one-dimension
Convolution
Ref: 出自台大電機系李宏毅老師 Machine Learning 課程投影片
Convolution
Ref: 出自台大電機系李宏毅老師 Machine Learning 課程投影片
● Convolution Filters 的長相
Convolution
Ref: https://medium.com/@RaghavPrabhu/understanding-of-convolutional-neural-network-cnn-deep-learning-99760835f148
from Stanford CS231n CNN: http://cs231n.github.io/convolutional-networks/
from cs231n:http://cs231n.stanford.edu/
Pooling
Ref: https://stats385.github.io/poolinglayers
Pooling
Ref: https://medium.com/@RaghavPrabhu/understanding-of-convolutional-neural-network-cnn-deep-learning-99760835f148
Convolutional Neural Network
64 convolution filters
pooling
R, G, B
Ref: https://hk.saowen.com/a/d2cde0a5e42606aae41a53e7ddb55ad7eb3208dc4cd218067344246a9a8ebf54
Convolutional Neural Network
● Understanding Neural Networks
Through Deep Visualization
Frameworks
Image Classification on Fashion MNIST Dataset
Environment Setting on Google Colab
● Google Colab:
https://colab.research.google.com/notebooks/welcome.ipynb#recent=true
● 文件 -> 新建 python3 Notebook
● 修改 -> 筆記本設置 -> GPU
Fashion MNIST Dataset
● Fashion MNIST Github
○ Total images 70000 (training dataset 60000, testing dataset 10000)
○ Resolution 28x28
○ Gray-scale
○ 10 classes:
Lab #1: Train DNN Model on Fashion MNIST
● Colab Notebook:
https://colab.research.google.com/drive/174_6xXG1up-GD6Ui
rXYMzMJYxyCdaPSD
Lab #2: Train CNN Model on Fashion MNIST
● Colab Notebook:
https://colab.research.google.com/drive/1eXKrKBe0lbsV9Ex6
amryF0Pml8QsySqY
Prepare Your Data for Image Classification
Prepare Data
Sample data:
https://drive.google.com/drive/folders/1-Wc10SNWg8UZ77wTmIs9JU2x_UYWvpI5?usp=s
haring
Train Your Image Classification Model
Lab #3: Train Your Image Classificaiton Model
● Colab Notebook:
https://colab.research.google.com/drive/1Sct4c6UUse5heNgF
fgdP-MckjCJ3umFM
照片辨識PK - 你能比 AI 準嗎?
● ImageNet Validation Set Competition
https://cs.stanford.edu/people/karpathy/ilsvrc/
Thank You

More Related Content

PPTX
Neural network
PPTX
Ultrasound nerve segmentation, kaggle review
PPTX
Image classification using cnn
PPTX
Batch normalization presentation
PDF
Neural network in matlab
PDF
Workshop - Introduction to Machine Learning with R
PPT
Neural tool box
PPTX
Artificial Neural Network
Neural network
Ultrasound nerve segmentation, kaggle review
Image classification using cnn
Batch normalization presentation
Neural network in matlab
Workshop - Introduction to Machine Learning with R
Neural tool box
Artificial Neural Network

What's hot (20)

PDF
PPTX
Ultrasound Nerve Segmentation
PPTX
The Art Of Backpropagation
PDF
Introduction to Neural Network
PPTX
Kaggle review Planet: Understanding the Amazon from Space
PDF
Intro to Neural Networks
PPT
Artificial Neural Networks - ANN
PPTX
Deep Learning with TensorFlow: Understanding Tensors, Computations Graphs, Im...
PPTX
neural network
PDF
Deep Feed Forward Neural Networks and Regularization
PDF
Collaborative, Context Based Activity Control Method for Camera Networks
PDF
Unsupervised Computer Vision: The Current State of the Art
PDF
Distributed Deep Learning Using Java on the Client and in the Cloud
PPTX
Le Song, Assistant Professor, College of Computing, Georgia Institute of Tech...
PDF
Introduction to Convolutional Neural Networks
PPTX
Face Recognition: From Scratch To Hatch
PPTX
Artificial Neural Network(Artificial intelligence)
PPTX
Neural network
PPTX
Artificial neural networks (2)
PPTX
ANN load forecasting
Ultrasound Nerve Segmentation
The Art Of Backpropagation
Introduction to Neural Network
Kaggle review Planet: Understanding the Amazon from Space
Intro to Neural Networks
Artificial Neural Networks - ANN
Deep Learning with TensorFlow: Understanding Tensors, Computations Graphs, Im...
neural network
Deep Feed Forward Neural Networks and Regularization
Collaborative, Context Based Activity Control Method for Camera Networks
Unsupervised Computer Vision: The Current State of the Art
Distributed Deep Learning Using Java on the Client and in the Cloud
Le Song, Assistant Professor, College of Computing, Georgia Institute of Tech...
Introduction to Convolutional Neural Networks
Face Recognition: From Scratch To Hatch
Artificial Neural Network(Artificial intelligence)
Neural network
Artificial neural networks (2)
ANN load forecasting
Ad

Similar to Machine learning workshop I - image classification (20)

PPTX
Machine Learning, Deep Learning and Data Analysis Introduction
PDF
[系列活動] 手把手的深度學實務
PPTX
Baisc Deep Learning HandsOn
PDF
Hands-on Tutorial of Deep Learning
PDF
[系列活動] 手把手的深度學習實務
PDF
AIML4 CNN lab256 1hr (111-1).pdf
PDF
Image Classification (20230411)
 
PDF
a introduction for machine learning class
PDF
Introduction to deep learning using python
PDF
2_Image Classification.pdf
 
PPTX
Machine learning project
PDF
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習
PPTX
TechEvent Machine Learning
PPTX
Introduction to Neural Networks and Deep Learning from Scratch
PPTX
Ai in 45 minutes
PDF
AI/ML Fundamentals to advanced Slides by GDG Amrita Mysuru.pdf
PPTX
An introduction to Deep Learning with Apache MXNet (November 2017)
PDF
AIML2 DNN 3.5hr (111-1).pdf
PPTX
B4UConference_machine learning_deeplearning
PDF
딥러닝 중급 - AlexNet과 VggNet (Basic of DCNN : AlexNet and VggNet)
Machine Learning, Deep Learning and Data Analysis Introduction
[系列活動] 手把手的深度學實務
Baisc Deep Learning HandsOn
Hands-on Tutorial of Deep Learning
[系列活動] 手把手的深度學習實務
AIML4 CNN lab256 1hr (111-1).pdf
Image Classification (20230411)
 
a introduction for machine learning class
Introduction to deep learning using python
2_Image Classification.pdf
 
Machine learning project
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習
TechEvent Machine Learning
Introduction to Neural Networks and Deep Learning from Scratch
Ai in 45 minutes
AI/ML Fundamentals to advanced Slides by GDG Amrita Mysuru.pdf
An introduction to Deep Learning with Apache MXNet (November 2017)
AIML2 DNN 3.5hr (111-1).pdf
B4UConference_machine learning_deeplearning
딥러닝 중급 - AlexNet과 VggNet (Basic of DCNN : AlexNet and VggNet)
Ad

Recently uploaded (20)

PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPT
Mechanical Engineering MATERIALS Selection
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Construction Project Organization Group 2.pptx
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
additive manufacturing of ss316l using mig welding
PPTX
web development for engineering and engineering
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
Well-logging-methods_new................
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Mechanical Engineering MATERIALS Selection
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Construction Project Organization Group 2.pptx
UNIT 4 Total Quality Management .pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Model Code of Practice - Construction Work - 21102022 .pdf
additive manufacturing of ss316l using mig welding
web development for engineering and engineering
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Internet of Things (IOT) - A guide to understanding
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Well-logging-methods_new................
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Mitigating Risks through Effective Management for Enhancing Organizational Pe...

Machine learning workshop I - image classification