SlideShare ist ein Scribd-Unternehmen logo
1 von 85
누구나 TensorFlow!
J. Kang Ph.D.
Mobile Vision Learning
TensorflowLite, Convolutional neural networks, and Mobilenet v1
Jaewook Kang, Ph.D.
jwkang10@gmail.com
May. 2018
1
© 2018
MoT Lab
All Rights Reserved
누구나 TensorFlow!
J. Kang Ph.D.
 GIST EEC Ph.D. (2015)
 신호처리 과학자, 삽질러
 모두의 연구소 MoT 연구실 리더
 https://www.facebook.com/jwkkang
 좋아하는 것:
 통계적 신호처리 / 무선통신 신호처리
 C++ Native 라이브러리 구현
 Mobile Machine learning
 수영 덕력 6년
2
 대표논문:
Jaewook Kang, et al., "Bayesian Hypothesis Test using Nonparametric Belief Propagation for
Noisy Sparse Recovery," IEEE Trans. on Signal process., Feb. 2015
Jaewook Kang et al., "Fast Signal Separation of 2D Sparse Mixture via Approximate Message-
Passing," IEEE Signal Processing Letters, Nov. 2015
Jaewook Kang (강재욱)
소 개
누구나 TensorFlow!
J. Kang Ph.D.
1. 모바일에서 머신러닝을 한다는것
- Why on-device ML?
- 해결해줘야 하는 부분
3
누구나 TensorFlow!
J. Kang Ph.D.
모바일 머신러닝
Why on-device ML?
– Cloud ML의 제약
• UX 측면
4
누구나 TensorFlow!
J. Kang Ph.D.
모바일 머신러닝
Why on-device ML?
– Cloud ML의 제약
• UX 측면
– 서비스 반응 속도=
» 입력 데이터 업로드시간
» +클라우드 Inference 시간
» +결과 다운로드 시간
5
누구나 TensorFlow!
J. Kang Ph.D.
모바일 머신러닝
Why on-device ML?
– Cloud ML의 제약
• UX 측면
– 서비스 반응 속도
– 오프라인 상황
6
누구나 TensorFlow!
J. Kang Ph.D.
모바일 머신러닝
Why on-device ML?
– Cloud ML의 제약
• 데이터 소모 측면
– Inference할때마다
» server call 필요
» 입력데이터 업로드 필요
– 큰 데이터 소비 APP  순삭 ㅠ
7
누구나 TensorFlow!
J. Kang Ph.D.
모바일 머신러닝
Why on-device ML?
– Cloud ML의 제약
• 프라이버시 측면
– 개인화   프라이버시
– 개인화 서비스는 받고 싶은데 내데이터를 주는 건 싫다?
• 데이터 퓨젼의 어려움
– 한 클라우드 서비스에서 다양한 개인정보를 수집하기
어려움
» 모바일: 위치정보 / 사진 / 영상 /오디오
8
누구나 TensorFlow!
J. Kang Ph.D.
모바일 머신러닝
해결해줘야 하는 부분
– UX + 비용 측면  On-device inference
• 반응 속도 (Fast Response)
• 배터리 (Efficient Computation)
• 모델 사이즈
• 메모리 제한?
– 프라이버시 측면 On-device training
• 다른 사람 말고 내 얼굴을 잘 인식해라 이놈아
• Transfer learning?
• Personal Data fusion
9
누구나 TensorFlow!
J. Kang Ph.D.
모바일 머신러닝
해결해줘야 하는 부분
– UX + 비용 측면  On-device inference
• 반응 속도 (Fast Response)
• 배터리 (Efficient Computation)
• 모델 사이즈
• 메모리 제한?
– 프라이버시 측면 On-device training
• 다른 사람 말고 내 얼굴을 잘 인식해라 이놈아
• Transfer learning?
• Personal Data fusion
10
누구나 TensorFlow!
J. Kang Ph.D.
모바일 머신러닝
11
- 하이퍼커넥트 신범준님 발표자료 중 -
누구나 TensorFlow!
J. Kang Ph.D.
Google’s Big Picture
– Google’s Approach in Mobile ML env. (utblink)
 Pre-training model in cloud
 Local fine-Tuning with private data
in mobile APP
 Run prediction engine in mobile APP
 Do the same things in IoT
모바일 머신러닝
12
+
NN API
+
누구나 TensorFlow!
J. Kang Ph.D.
Google’s Big Picture
– Google’s Approach in Mobile ML env. (utblink)
 Pre-training model in cloud
 Local fine-Tuning with private data
in mobile APP
 Run prediction engine in mobile APP
 Do the same things in IoT
모바일 머신러닝
13
+
NN API
+
(2016)
(2015)
(2018)
(2017)
(2017)
누구나 TensorFlow!
J. Kang Ph.D.
About
❖A lightweight ML library and tool or mobile
devices
– https://www.tensorflow.org/mobile/tflite/
– 지원 플랫폼:
• Android Mobile
• Raspberry Pi 3 (Android Things)
• iOS
– 지원 ops: Tensorflow >= Tensorflow Lite
– 사이즈: Core Interpreter (+supp. Ops) 70kB ( 400kB)
– 버전: Developer preview (2017 Nov, w/ TF v1.5)
14
누구나 TensorFlow!
J. Kang Ph.D.
About
15
이미지 출처:
https://www.t
ensorflow.org/
mobile/tflite/
누구나 TensorFlow!
J. Kang Ph.D.
About
❖A lightweight ML library and tool or mobile
devices
16
Tflite모델을
각 플랫폼의 커널에서
사용할 수 있도록
번역하는 Api
(tflite로딩)
플랫폼 별 tflite
모델을 최적화
용 op set
on device HW
계산 자원 할당
최적화
이미지출처: https://www.youtube.com/watch?v=FAMfy7izB6A
- Android NNAPI
- iOS CoreML- Tensorflow lite framework
누구나 TensorFlow!
J. Kang Ph.D.
About
❖A lightweight ML library and tool or mobile
devices
17
Run on device!
Run on device!
Run on device!
이미지출처: https://www.youtube.com/watch?v=FAMfy7izB6A
- Android NNAPI
- iOS CoreML- Tensorflow lite framework
누구나 TensorFlow!
J. Kang Ph.D.
About
❖A lightweight ML library and tool or mobile
devices
– iOS develop has another option!
– coreML converter 따로 있음: tfcoreml github repo
• (tflite+coreml >>10배 속도>> tflite+nnapi)
18
이미지출처: https://www.youtube.com/watch?v=FAMfy7izB6A
누구나 TensorFlow!
J. Kang Ph.D.
About
❖Why TensorFlow Lite is faster?
– FlatBuffer:
• A new model file format
– Operation kernels optimized for NEON on ARM
– Hardware acceleration support
• Android NN API (Android Oreo)
– Qualcomm Hexagon DSP SDK (Android P)
– Direct GPU support
• iOS CoreML
– Metal2
– Quantization: Integer-arithmetic only support
• Quantize both weights and activation as 8-bit integers
• Just a few parameters(bias vectors) as 32-bit integers
• 가장 범용적인 multiply-add instruction HW에서의 개선
• 용량 줄이기 보다 Inference 속도개선에 집중
19
누구나 TensorFlow!
J. Kang Ph.D.
Android Neural Network API
❖ Android NN API 개요
– On-deivce에서 계산효율적 ML을 위해서 설계된 Android C/C++ API
– TensorFlow Lite 모델은 Android NN API의 Kernel Interpreter로 재구
성 + 최적화 되어 계산 하드웨어에 연결됨.
– Hardware-specific processing을 통해서 neural net inference 속도 개
선!
• Android 에서 잘 돌아가도록 tflite모델을 재구성 + 계산 자원 분배
• 디바이스가 보유하는 계산 유닛(CPU/CPU/DSP)에 효율적으로 계산 workload를
할당 할 예정
• 현재는 CPU만 지원됨 (2018 Mar)
– Supporting Android 8.1 (API level 27 + NDK level 14) or higher
• - tflite + nnapi : api level >= 27, ndk level > 14 (neon arm processor 에 최적화)
• - tflite only : api level >=21 (안빠름)
– tflite는 nnapi가 없어도 돌지만 그 경우 전혀 빠르지 않다!
20
This slide is
powered by J. Lee
누구나 TensorFlow!
J. Kang Ph.D.
Android Neural Network API
❖ Android NN API 개요
–
21
This slide is
powered by J. Lee
1) .tflite파일를 JAVA/C++ API
을 통해서 로드해서
2) C++ Android Kernal (Core)
Interpreter를 통해서 NNAPI
클래스로 넘겨주고
3) C++ NNAPI Op set을 이용해
서 내부에서 tflite 모델을 low-
level로 내부적으로 빌드한다.
(최적화)
4) low-level tflite 모델을
NNAPI를 통해서 실행한다.
누구나 TensorFlow!
J. Kang Ph.D.
2. Recent Trends of Vision Networks
- CNN Concept
- Recent Trends
22
누구나 TensorFlow!
J. Kang Ph.D.
Some References
 Standford cs231n 2018
– http://cs231n.stanford.edu
23
누구나 TensorFlow!
J. Kang Ph.D.
질문: 계산량이 가장 많고 프라이버시에 민감하며
동시에 정보량이 가장 큰 데이터?
24
누구나 TensorFlow!
J. Kang Ph.D.
모바일 머신러닝
계산량이 가장 많고 프라이버시에 민감하며
동시에 정보량이 가장 큰 데이터?
25 이미지출처: http://cs231n.stanford.edu
누구나 TensorFlow!
J. Kang Ph.D.
모바일 머신러닝
계산량이 가장 많고 프라이버시에 민감하며
동시에 정보량이 가장 큰 데이터?
26 이미지출처: http://cs231n.stanford.edu
누구나 TensorFlow!
J. Kang Ph.D.
Convolutional Neural Networks (CNN)
Convolutional neural network (CNN) 는 아주
중요하게 되었습니다.
– 시각인식
– 신호처리
– 분석 도구
27 이미지출처: http://cs231n.stanford.edu
누구나 TensorFlow!
J. Kang Ph.D.
CNN을 한마디로 요약하면?
Convolutional Neural Networks (CNN)
28
한 layer에 대해서
기존 Fully connected networks 에서 input X과 logit Z 사이의 관계를 “Matrix
Multiplication”으로 표현했던 것을
“Convolution”으로 대체하여 표현하여 계산효율성/overfitting을 개선한
networks.
이미지출처: https://www.safaribooksonline.com/library/view/learning-tensorflow/9781491978504/ch04.html
Logit: Z
Input: X
누구나 TensorFlow!
J. Kang Ph.D.
CNN is Biologically Inspired!
Emerged from the study of the brain’s visual cortex
– Visual system의 뉴런은 전체를 보지 않는다!
• Retina 뉴런은 제한된 영역의 “local receptive field”를 가진다.
• Local receptive field 에서 Edge와 같은 “low-level feature”를 인식한다.
29
이미지출처: https://www.slideshare.net/GauravMittal68/convolutional-neural-networks-cnn
누구나 TensorFlow!
J. Kang Ph.D.
CNN is Biologically Inspired!
Emerged from the study of the brain’s visual cortex
– 상위 layer의 뉴런은 에서는 Retina 뉴런에서 인식한 ”Low-level
features”를 복합적으로 결합하여 “High-level features”를 구성한다.
– High-level feature들은 단계적으로 결합되어 “Entire objects
pattern”를 구성하고 뇌에서 인지 한다.
30
이미지출처: https://www.slideshare.net/GauravMittal68/convolutional-neural-networks-cnn
Area V1 Area V2 Area V3 Area V4Retina
Edges Object parts Entire objects
누구나 TensorFlow!
J. Kang Ph.D.
CNN을 구성하는 layers
– Convolutional layer
• Generation of feature map (layer output)
• Local feature reception and combination
– Pooling layer
• Spatial / temporal sub-sampling of features
31
누구나 TensorFlow!
J. Kang Ph.D.
CNN Basic Architectures
Stacking of (Conv layer + pooling layer)
– 기본적으로 Conv layer + pool layer를 쌓는 방식
– Output layer 바로 전 몇 단은 FNN을 쌓는다
– Application에 따라서 다양한 configuration이 존재
32
누구나 TensorFlow!
J. Kang Ph.D.
모바일 머신러닝
계산량이 가장 많고 프라이버시에 민감하며
동시에 정보량이 가장 큰 데이터?
33 이미지출처: http://cs231n.stanford.edu
누구나 TensorFlow!
J. Kang Ph.D. 34 이미지출처: http://cs231n.stanford.edu
ImageNet Top-5 error rate
누구나 TensorFlow!
J. Kang Ph.D.
CNN Benchmark Map
 목적: 모바일에도 올릴 수 있는 효율적인 모델을 만들고 싶다!
35
https://www.topbots.com/a-brief-history-of-
neural-network-architectures/
Good Region
Bad Region
누구나 TensorFlow!
J. Kang Ph.D.
Comparison to Mobile App Size
 대한민국 상위 앱 (안드로이드 기준, 2018 Jan)
• 카카오톡: 83.98 MB 네이버: 128 MB
• Facebook: 67.97 MB Chrome: 178 MB
36
누구나 TensorFlow!
J. Kang Ph.D.
3. Why Depthwise separable convolution? :
From Inception to Xception and MobileNet v1
- Szegedy etal, ”Going depper with convolutions,” 2014
- A.G. Howard et al. “MobileNets: Efficient Convolutional Neural Networks for Mobile
Vision Applications”, CoRR, 2017.
- F. Chollet, “Xception: Deep Learning with Depthwise Separable Convolution,” 2017
Convolution 연산량과 파라미터 수좀 줄여보자!
37
누구나 TensorFlow!
J. Kang Ph.D.
How to build model for mobile
 목적: 모바일에도 올릴 수 있는 효율적인 CNN 모델을 만들고 싶다!
38
Recent advances are not necessarily making network
more efficient with respect to size and speed!!!
누구나 TensorFlow!
J. Kang Ph.D.
How to build model for mobile
 목적: 모바일에도 올릴 수 있는 효율적인 모델을 만들고 싶다!
– 방향1: Layer width와 network depth를 무작정 늘리는 것은 우리가
가야 할 방향이 아니다!
• Depth : layer의 개수  Ability of object abstraction
• Width: 한 layer의 파라미터 개수  Ability of feature abstraction in one
layer
– 방향2: 모델사이즈와 성능의 trade-off를 쉽게 조절할 수 있는 meta-
parameter를 설정해야한다.
• 코드에 대한 큰 수정 없이 간단하게 trade-off를 조절할 수 있어야 한다.
39
Recent advances are not necessarily making network
more efficient with respect to size and speed!!!
누구나 TensorFlow!
J. Kang Ph.D.
How to build model for mobile
 핵심질문: 계산 복잡도/사이즈를 줄이면서 conv layer의 표현력을
유지 할수 있는가? (효율적인 feature extraction)
40
누구나 TensorFlow!
J. Kang Ph.D.
How to build model for mobile
 핵심질문: 계산 복잡도/사이즈를 줄이면서 conv layer의 표현력을
유지 할수 있는가? (효율적인 feature extraction)
– Depthwise separable convolution!
41
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution
 근데 사실 Mobilenet에 보다 Xception에서 먼저 사용한 용어
– F. Chollet, “Xception: Deep Learning with Depthwise Separable
Convolutions,” arXiv: 1610.02357, 2016
– Depthwise separable convolution의 기원을 알고싶은면 봐야한다.
42
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Xception
 핵심가설: The mapping of “cross-channels correlation”
and “spatial correlation” can be entirely decoupled!
 무슨 말인가?
43
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Xception
 핵심가설: The mapping of “cross-channels correlation”
and “spatial correlation” can be entirely decoupled!
 무슨 말인가?
– Cross-channel correlation: conv layer에 입력되는 채널 간의 비슷한
정도
44
High cross-channel correlation!
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Xception
 핵심가설: The mapping of “cross-channels correlation”
and “spatial correlation” can be entirely decoupled!
 무슨 말인가?
– Cross-channel correlation: conv layer에 입력되는 채널 간의 비슷한
정도
45
Very? Low cross-channel correlation!
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Xception
 핵심가설: The mapping of “cross-channels correlation”
and “spatial correlation” can be entirely decoupled!
 무슨 말인가?
– Spatial correlation: conv filter와 입력 채널 사이의 상관도
46Conv filter
이미지출처: http://user-
image.logdown.io/user/136
73/blog/12890/post/30264
1/V21DnAAeTKiOirZRFKhT_
dl2.png
Low correlation
High correlation
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Xception
 핵심가설: The mapping of “cross-channels correlation”
and “spatial correlation” can be entirely decoupled!
 무슨 말인가?
– Spatial correlation: conv filter와 입력 채널 사이의 상관도
– High spatial correlation: 해당 conv filter로 feature extraction이
잘된다.
– Low spatial correlation: 해당 conv filter로 feature extraction이 잘
안된다.
47Conv filter
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Xception
 핵심가설: The mapping of “cross-channels correlation”
and “spatial correlation” can be entirely decoupled!
 무슨 말인가?
– “입력 채널간의 유사도”와 “filter가 채널에서 뽑아내는 spatial
feature”간은 상관이 없을 것이라는 가설
– 다시말해서 입력 채널이 어떤 구성으로 들어와도 feature
extraction에는 영향이 크지 않을꺼다!
– 그러면 filtering을 할때 입력 채널을 묶어서 하지 않아도 되지
않는가?
 …… 하는 가설!
48
누구나 TensorFlow!
J. Kang Ph.D.
Short Note for Inception Module
 본 가설은 사실 “Inception”에서 부터 고려됐음
– Ref: Szegedy etal, Going deeper with convolutions, 2014
 Cross channel pooling by 1x1 conv (Dimensionality reduction):
– 1x1 conv를 통해서 cross channel pooling을 수행하여 3x3, 5x5 conv에서의
연산량을 줄임
– Feature extraction할때 cross channel correlation은 크게 영향이 없으니 1x1
conv로 좀 입력을 압축해서 넣을 수 있지 않나?
 Combination of parallel conv paths:
– Layer input을 1x1, 3x3, 5x5 conv path로 병렬적으로 처리 한후
concatenation해서 출력
– Spatial correlation은 conv filter사이즈 마다 다르게 추출 될 것이다.
49
누구나 TensorFlow!
J. Kang Ph.D.
Short Note for Inception Module
50
Dimensionality
reduction
Capturing correlation
From local clusters
Inception module v1
이미지 출처: Szegedy etal, Going
deeper with convolutions, 2014
Dimensionality
reduction
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Xception
51
이미지출처:
https://arxiv.org/abs/1610.02357
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Xception
52
이미지출처:
https://arxiv.org/abs/1610.02357
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Xception
53
이미지출처:
https://arxiv.org/abs/1610.02357
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Xception
54
이미지출처:
https://arxiv.org/abs/1610.02357
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Mobilenet
55
Depthwise separable conv in Mobilenet
– Ref.: A.G. Howard et al. “MobileNets: Efficient Convolutional Neural Networks
for Mobile Vision Applications”, CoRR, 2017.
Standard conv DW conv
누구나 TensorFlow!
J. Kang Ph.D.
Xception vs Mobilenet
Xception (2016):
– Pwise convolution 먼저
– Single Pwise conv + 7 Dwise conv
– Optionally 중간에 Relu non-linearity를 둘 수 있음
– Grid (channel) size reduction에 Max-pooling사용
– Shortcut connection사용
Mobilenet (2017):
– Dwise convolution 먼저
– Single Dwise conv + Single Pwise conv
– 중간 Relu non-linearity 없음
– Grid (channel) size reduction에 stride-2 conv사용
– Meta parameters!
 구현이 다르지만 같은 가설에 기반함
56
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Mobilenet
 핵심질문: 계산 복잡도/사이즈를 줄이면서 conv layer의 표현력을
유지 할수 있는가?
– Standard 3D convolution (입력 채널개수가 L개 경우)
• Input channel : N x N x L
• Filter size (weight) : K x K x L (x M)
• Output channel: (N-K)+1 x (N-K)+1 (No zero padding)
– 복잡도:
• 3D conv 수행
– Conv의 sliding은 2D 방향으로만
– 각 채널의 3D conv결과를 sum-up
– N^2 x K^2 x L
• 필터 개수: M
• Total:
– N^2 x K^2 x L x M
57
이미지출처: http://machinethink.net/blog/googles-mobile-net-
architecture-on-iphone/
Filter Size : K x K x L (x M) ,
where K=3, L=3
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Mobilenet
 핵심질문: 계산 복잡도/사이즈를 줄이면서 conv layer의 표현력을
유지 할수 있는가?
 Depthwise separable convolution
– 답: 3D conv 필터링 하지말구… Depthwise-separable conv하자!
• Step 1) Depthwise conv (Dwise):
– 동일 2D conv필터로 L개 입력채널을 각각 필터링
• Step 2) Pointwise conv (Pwise):
– Dwise conv 결과에 대해서 1 x 1 x L (x M) conv를 수행
58
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Mobilenet
 핵심질문: 계산 복잡도를 줄이면서 conv layer의 표현력을 유지 할수
있는가?
– Dwise conv + Pwise conv로 분할 계산 (L개 채널입력)
• Input channel : N x N x L
• Dwise Filter size (weight) : K x K x 1
• Pwise 1x1 filter: 1 x 1 x L X (M)
59
이미지출처: http://machinethink.net/blog/googles-mobile-net-
architecture-on-iphone/
Depthwise Conv Pointwise Conv
Dwise Filter Size : K x K x 1
(K=3)
Pwise Filter Size : 1 x 1 x L (x M)
(L=3)
+
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Mobilenet
 핵심질문: 계산 복잡도를 줄이면서 conv layer의 표현력을 유지 할수
있는가?
– Dwise conv:
• N x N x L  (N-K)+1 x (N-K)+1 x L
– Pwise conv:
• (N-K)+1 x (N-K)+1 x L  (N-K)+1 x (N-K)+1 x 1
– 복잡도:
• Dwise conv: N^2 x K^2 x L
• Pwise conv: {(N-K)+1}^2 x L
• Total (M 개 필터):
– N^2 x K^2 x L + {(N-K)+1}^2 x L x M
60
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Mobilenet
 복잡도는 얼마나 줄어드는가? (Mult-Adds)
– Standard conv:
– Depthwise-separable conv (N >> K):
– Complexity ratio:
– 필터 크기 K가 dominant!, K가 크다  복잡도 크게 개선
– 필터 개수 M가 크다  복잡도 크게 개선
– K=3 인경우 8~9배 절약
61
N2
K2
LM
N2
K2
L + N2
LM
Mobilenet
Standard
=
N2
K2
L + N2
LM
N2
K2
LM
=
1
M
+
1
K2
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Mobilenet
 파라미터 수는 얼마나 줄어드는가? (Parameters)
– Standard conv:
– Depthwise-separable conv:
– Parameter number ratio :
62
Mobilenet
Standard
=
(K2
+1)+ (L +1)M
(K2
L +1)M
K2
<<LM
¾ ®¾¾¾
L +1
K2
L +1
»
1
K2
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Mobilenet
 모델 복잡도 / 사이즈 정량적 지표!
 Case for K=3, N=14, L=512, M=512
– Million Mult-Adds (복잡도*10^-6):
• Std conv:
• DW conv:
–  52/462 = 0.11 ~= 1/9 (=1/K^2)
– Million Parameters (파라미터수 *10^-6):
• Std conv:
• DW conv:
– 0.26/2.35 =0.11 ~= 1/9 (=1/K^2)
63
142
×9×512×512´10-6
= 462.422016
142
×9×512+142
×512×512( )´10-6
= 52.283392
(9×512 +1)×512 ´10-6
= 2.359808
(9 +1)+ (512 +1)×512( )´10-6
= 0.262666
누구나 TensorFlow!
J. Kang Ph.D.
Depthwise separable convolution: Mobilenet
 모델 복잡도 / 사이즈 정량적 지표!
 Case for K=3, N=14, L=512, M=512
64
누구나 TensorFlow!
J. Kang Ph.D.
Width / Resolution Multiplier
 핵심질문: 모델사이즈를 간단하게 조절하고 싶다!
 Width multiplier ( )
– Conv layer 의 입출력 채널 개수(L,M) 를 조절하는 meta parameter
– 모델 파라미터 수에 영향
– 연산량에도 영향
 Resolution multiplier ( )
– 입력 채널의 사이즈 (N) 을 조절하는 meta parameter
– 모델 파라미터 수에 영향 없음
– 연산량에는 영향
65
a Î(0,1]
r Î(0,1]
ar2
L(N2
K2
+aN2
M)
누구나 TensorFlow!
J. Kang Ph.D.
Width / Resolution Multiplier
 Meta parameter 조절에 따른 ImageNet Top-1 accuracy
– 이름:
66
a Î(0,1]
r Î(0,1]
aMobileNet-rNin (where Nin = 224)
With respect to
With respect to
누구나 TensorFlow!
J. Kang Ph.D. 67
•Mobilenet_quant_v1_224.tflite
•테스트 디바이스: Samsung Galaxy S7
(SM-G930L) + Android 7.0 (Nougat)
•빌드 환경:
• Mac OSX 10.11.6
• bazel Version : 0.7
• Android Studio 3.0
• Android Build Tools Level: 26.1.1
• Android NDK Version: 16.04442984
1.mobilenet_v1_1.0_224 : 67.9 MB, Top-1
Accuracy=70.7, Top-5 Accuracy=89.5
2.mobilenet_quant_v1_224.tflite: 4.3 MB,
Top-1 Accuracy=??, Top-5 Accuracy=??
누구나 TensorFlow!
J. Kang Ph.D.
Efficient grid size reduction with stride 2
 핵심질문: Max pooling layer를 두는 것은 정보량을 손실하는 것이기
때문에 모델의 expressiveness를 열화시키지 않나요 ?
– 이건 inception v2에서 부터 했던 얘기
• Ref: Szegedy etal, Rethinking the inception Arch. for computer vision
– Mobilenet논문에는 이유에 대한 언급이 없음
– 그럼 inception v2으로 한번 돌아가보자!
68
누구나 TensorFlow!
J. Kang Ph.D.
Efficient grid size reduction with stride 2
 Feature map의 grid size (N)를 pooling이 아닌 stride를 이용해서 줄이자!
– GoogLeNet에서는 inception module 앞에 max-pooling layer을
삽입하여 grid size을 줄여왔다.
•  계산량 감소!
69
누구나 TensorFlow!
J. Kang Ph.D.
Efficient grid size reduction with stride 2
70
누구나 TensorFlow!
J. Kang Ph.D.
 Feature map의 grid size (N) 를 pooling이 아닌 stride를 이용해서 줄이자!
– GoogLeNet에서는 inception module 앞에 max-pooling layer을
삽입하여 grid size을 줄여왔다.
 Pooling은 연산량을 줄일 수 있지만 representational bottleneck을
야기한다.
 Pooling layer를 두지 말고 Inception module안의 conv layer의 stride를
사용하여 grid size reduction을 하자!
 질문) 이방법이 왜 max-pooing보다 expressiveness를 제한하지
않는가????
71
Efficient grid size reduction with stride 2
누구나 TensorFlow!
J. Kang Ph.D.
Efficient grid size reduction with stride 2
 Input image: 427x640  output images: 211x317
 Filtersize = 7 x 7
– 1) Std conv (stride=1)+ maxpool (tilesize = 7, stride2)
– 2) stride 2 conv
누구나 TensorFlow!
J. Kang Ph.D.
Efficient grid size reduction with stride 2
73
 Input image: 427x640  output images: 211x317
 Filtersize = 7 x 7
– 1) Std conv (stride=1)+ maxpool (tilesize = 7, stride2)
– 2) stride 2 conv
Vertical filtering Horizontal filtering Vertical filtering Horizontal filtering
누구나 TensorFlow!
J. Kang Ph.D.
 질문) 이방법이 왜 max-pooing보다 expressiveness를 제한하지
않는가????
– 가설:
• Stride 2 conv: 훈련과정에서 stride-2에 의한 정보손실을
최소화하는 방향으로 filter을 학습 시킬 수 있음
•  Soft downsampling
• Max-pooling: 훈련과정에서 pooling에 의한 정보손실을 만회할
수 있는 여지가 없음
•  Hard downsamping
74
Efficient grid size reduction with stride 2
누구나 TensorFlow!
J. Kang Ph.D.
 Feature map의 grid size (N) 를 pooling이 아닌 stride를 이용해서 줄이자!
75
Pooling and then Inception
(GoogLeNet)
Stride 2 convolution in Inception
(Inception v2- )
Efficient grid size reduction with stride 2
Grid size ½:
35  17
누구나 TensorFlow!
J. Kang Ph.D.
Mobilenet Architecture
76
 Remarks
• All layers are followed by
batch normalization and ReLu
• The first conv layer adopts
a standard conv
• Use stride-2 conv alternatively
• Use FC layer for the classification layer
with softmax activation
• Use l2 weight decay
• Use a RMSprop optimizer
누구나 TensorFlow!
J. Kang Ph.D.
Accuracy Comparison to others (1/2)
77
Squeezenet과
비슷한
모델사이즈로
비교
누구나 TensorFlow!
J. Kang Ph.D.
Accuracy Comparison to others (2/2)
78
누구나 TensorFlow!
J. Kang Ph.D.
Keys for success of Mobilenet v1
 Depthwise-separable-convolution to reduce complexity of
convolution layers
 Efficient grid size reduction with stride 2 convolution
 Meta parameters to control size and complexity of model
– Width multiplier to regulate model size and complexity by controlling
I/O channel numbers.
– Resolution multiplier to regulate complexity by controlling the size of
input channels to each layer.
79
누구나 TensorFlow!
J. Kang Ph.D.
모두연 MoT랩 소개
딥러닝을 활용하여 세상을 이롭게 할 IoT/Mobile
App 개발에 대한 연구를 같이 해봐요!!
 https://www.facebook.com/lab4all/posts/761099760749661
 jwkang10@gmail.com 로 메일
Keywords:
– Thin CNN Model
– Model optimization
– Tensorflow + lite
– Embedded Sys. (IoT)
– Android Mobile/Things
80
누구나 TensorFlow!
J. Kang Ph.D.
MoT Contributors
Jaewook Kang
(Soundlly)
Joon ho Lee
(Neurophet)
Yonggeun Lee Jay Lee
(KakaoPay)
SungJin Lee
(DU)
Seoyoen Yang
(SNU)
Taekmin Kim
(SNU)
Jihwan Lee
(SNU)
Doyoung Kwak
(PU)
Yunbum Beak
(신호시스템)
Joongwon Jwang
(위메프)
Jeongah Shin
(HanyangUniv)
누구나 TensorFlow!
J. Kang Ph.D. 82
누구나 TensorFlow!
J. Kang Ph.D.
Google Deep learning Jeju Camp 2018
83
24 accepted from 562 and 50+ countries
경쟁율 1 대 24
MoT에서 3명 참가 !
Seoyoen Yang (SNU) Taekmin Kim (SNU)Jaewook Kang (Soundlly)
누구나 TensorFlow!
J. Kang Ph.D. 84
누구나 TensorFlow!
J. Kang Ph.D. 85
The End
Mobile Vision Learning 2018
- All right reserved @ Jaewook Kang 2018

Weitere ähnliche Inhalte

Was ist angesagt?

[Tf2017] day2 jwkang_pub
[Tf2017] day2 jwkang_pub[Tf2017] day2 jwkang_pub
[Tf2017] day2 jwkang_pubJaewook. Kang
 
[Tf2017] day3 jwkang_pub
[Tf2017] day3 jwkang_pub[Tf2017] day3 jwkang_pub
[Tf2017] day3 jwkang_pubJaewook. Kang
 
기계 학습의 현재와 미래
기계 학습의 현재와 미래기계 학습의 현재와 미래
기계 학습의 현재와 미래Joon Kim
 
Tensorflow for Deep Learning(SK Planet)
Tensorflow for Deep Learning(SK Planet)Tensorflow for Deep Learning(SK Planet)
Tensorflow for Deep Learning(SK Planet)Tae Young Lee
 
한글 언어 자원과 R: KoNLP 개선과 활용
한글 언어 자원과 R: KoNLP 개선과 활용한글 언어 자원과 R: KoNLP 개선과 활용
한글 언어 자원과 R: KoNLP 개선과 활용r-kor
 
순환신경망(Recurrent neural networks) 개요
순환신경망(Recurrent neural networks) 개요순환신경망(Recurrent neural networks) 개요
순환신경망(Recurrent neural networks) 개요Byoung-Hee Kim
 
인공지능 방법론 - Deep Learning 쉽게 이해하기
인공지능 방법론 - Deep Learning 쉽게 이해하기인공지능 방법론 - Deep Learning 쉽게 이해하기
인공지능 방법론 - Deep Learning 쉽게 이해하기Byoung-Hee Kim
 
[기초개념] Recurrent Neural Network (RNN) 소개
[기초개념] Recurrent Neural Network (RNN) 소개[기초개념] Recurrent Neural Network (RNN) 소개
[기초개념] Recurrent Neural Network (RNN) 소개Donghyeon Kim
 
Deep learning framework 제작
Deep learning framework 제작Deep learning framework 제작
Deep learning framework 제작Tae Young Lee
 
The bleeding edge of machine learning stream in 2017 - APAC ML/DS Community ...
The bleeding edge of  machine learning stream in 2017 - APAC ML/DS Community ...The bleeding edge of  machine learning stream in 2017 - APAC ML/DS Community ...
The bleeding edge of machine learning stream in 2017 - APAC ML/DS Community ...Jeongkyu Shin
 
[224] backend 개발자의 neural machine translation 개발기 김상경
[224] backend 개발자의 neural machine translation 개발기 김상경[224] backend 개발자의 neural machine translation 개발기 김상경
[224] backend 개발자의 neural machine translation 개발기 김상경NAVER D2
 
[226]대용량 텍스트마이닝 기술 하정우
[226]대용량 텍스트마이닝 기술 하정우[226]대용량 텍스트마이닝 기술 하정우
[226]대용량 텍스트마이닝 기술 하정우NAVER D2
 
딥러닝 자연어처리 - RNN에서 BERT까지
딥러닝 자연어처리 - RNN에서 BERT까지딥러닝 자연어처리 - RNN에서 BERT까지
딥러닝 자연어처리 - RNN에서 BERT까지deepseaswjh
 
딥러닝을 이용한 자연어처리의 연구동향
딥러닝을 이용한 자연어처리의 연구동향딥러닝을 이용한 자연어처리의 연구동향
딥러닝을 이용한 자연어처리의 연구동향홍배 김
 
파이썬으로 익히는 딥러닝 기본 (18년)
파이썬으로 익히는 딥러닝 기본 (18년)파이썬으로 익히는 딥러닝 기본 (18년)
파이썬으로 익히는 딥러닝 기본 (18년)SK(주) C&C - 강병호
 
[221] 딥러닝을 이용한 지역 컨텍스트 검색 김진호
[221] 딥러닝을 이용한 지역 컨텍스트 검색 김진호[221] 딥러닝을 이용한 지역 컨텍스트 검색 김진호
[221] 딥러닝을 이용한 지역 컨텍스트 검색 김진호NAVER D2
 
[한국어] Neural Architecture Search with Reinforcement Learning
[한국어] Neural Architecture Search with Reinforcement Learning[한국어] Neural Architecture Search with Reinforcement Learning
[한국어] Neural Architecture Search with Reinforcement LearningKiho Suh
 
텐서플로우 설치도 했고 튜토리얼도 봤고 기초 예제도 짜봤다면 TensorFlow KR Meetup 2016
텐서플로우 설치도 했고 튜토리얼도 봤고 기초 예제도 짜봤다면 TensorFlow KR Meetup 2016텐서플로우 설치도 했고 튜토리얼도 봤고 기초 예제도 짜봤다면 TensorFlow KR Meetup 2016
텐서플로우 설치도 했고 튜토리얼도 봤고 기초 예제도 짜봤다면 TensorFlow KR Meetup 2016Taehoon Kim
 
딥러닝 - 역사와 이론적 기초
딥러닝 - 역사와 이론적 기초딥러닝 - 역사와 이론적 기초
딥러닝 - 역사와 이론적 기초Hyungsoo Ryoo
 

Was ist angesagt? (20)

[Tf2017] day2 jwkang_pub
[Tf2017] day2 jwkang_pub[Tf2017] day2 jwkang_pub
[Tf2017] day2 jwkang_pub
 
[Tf2017] day3 jwkang_pub
[Tf2017] day3 jwkang_pub[Tf2017] day3 jwkang_pub
[Tf2017] day3 jwkang_pub
 
기계 학습의 현재와 미래
기계 학습의 현재와 미래기계 학습의 현재와 미래
기계 학습의 현재와 미래
 
Tensorflow for Deep Learning(SK Planet)
Tensorflow for Deep Learning(SK Planet)Tensorflow for Deep Learning(SK Planet)
Tensorflow for Deep Learning(SK Planet)
 
한글 언어 자원과 R: KoNLP 개선과 활용
한글 언어 자원과 R: KoNLP 개선과 활용한글 언어 자원과 R: KoNLP 개선과 활용
한글 언어 자원과 R: KoNLP 개선과 활용
 
순환신경망(Recurrent neural networks) 개요
순환신경망(Recurrent neural networks) 개요순환신경망(Recurrent neural networks) 개요
순환신경망(Recurrent neural networks) 개요
 
인공지능 방법론 - Deep Learning 쉽게 이해하기
인공지능 방법론 - Deep Learning 쉽게 이해하기인공지능 방법론 - Deep Learning 쉽게 이해하기
인공지능 방법론 - Deep Learning 쉽게 이해하기
 
[기초개념] Recurrent Neural Network (RNN) 소개
[기초개념] Recurrent Neural Network (RNN) 소개[기초개념] Recurrent Neural Network (RNN) 소개
[기초개념] Recurrent Neural Network (RNN) 소개
 
Deep learning framework 제작
Deep learning framework 제작Deep learning framework 제작
Deep learning framework 제작
 
The bleeding edge of machine learning stream in 2017 - APAC ML/DS Community ...
The bleeding edge of  machine learning stream in 2017 - APAC ML/DS Community ...The bleeding edge of  machine learning stream in 2017 - APAC ML/DS Community ...
The bleeding edge of machine learning stream in 2017 - APAC ML/DS Community ...
 
[224] backend 개발자의 neural machine translation 개발기 김상경
[224] backend 개발자의 neural machine translation 개발기 김상경[224] backend 개발자의 neural machine translation 개발기 김상경
[224] backend 개발자의 neural machine translation 개발기 김상경
 
[226]대용량 텍스트마이닝 기술 하정우
[226]대용량 텍스트마이닝 기술 하정우[226]대용량 텍스트마이닝 기술 하정우
[226]대용량 텍스트마이닝 기술 하정우
 
딥러닝 자연어처리 - RNN에서 BERT까지
딥러닝 자연어처리 - RNN에서 BERT까지딥러닝 자연어처리 - RNN에서 BERT까지
딥러닝 자연어처리 - RNN에서 BERT까지
 
딥러닝을 이용한 자연어처리의 연구동향
딥러닝을 이용한 자연어처리의 연구동향딥러닝을 이용한 자연어처리의 연구동향
딥러닝을 이용한 자연어처리의 연구동향
 
파이썬으로 익히는 딥러닝 기본 (18년)
파이썬으로 익히는 딥러닝 기본 (18년)파이썬으로 익히는 딥러닝 기본 (18년)
파이썬으로 익히는 딥러닝 기본 (18년)
 
파이썬으로 익히는 딥러닝
파이썬으로 익히는 딥러닝파이썬으로 익히는 딥러닝
파이썬으로 익히는 딥러닝
 
[221] 딥러닝을 이용한 지역 컨텍스트 검색 김진호
[221] 딥러닝을 이용한 지역 컨텍스트 검색 김진호[221] 딥러닝을 이용한 지역 컨텍스트 검색 김진호
[221] 딥러닝을 이용한 지역 컨텍스트 검색 김진호
 
[한국어] Neural Architecture Search with Reinforcement Learning
[한국어] Neural Architecture Search with Reinforcement Learning[한국어] Neural Architecture Search with Reinforcement Learning
[한국어] Neural Architecture Search with Reinforcement Learning
 
텐서플로우 설치도 했고 튜토리얼도 봤고 기초 예제도 짜봤다면 TensorFlow KR Meetup 2016
텐서플로우 설치도 했고 튜토리얼도 봤고 기초 예제도 짜봤다면 TensorFlow KR Meetup 2016텐서플로우 설치도 했고 튜토리얼도 봤고 기초 예제도 짜봤다면 TensorFlow KR Meetup 2016
텐서플로우 설치도 했고 튜토리얼도 봤고 기초 예제도 짜봤다면 TensorFlow KR Meetup 2016
 
딥러닝 - 역사와 이론적 기초
딥러닝 - 역사와 이론적 기초딥러닝 - 역사와 이론적 기초
딥러닝 - 역사와 이론적 기초
 

Ähnlich wie 180525 mobile visionnet_hanlim_extended

스마트폰 위의 딥러닝
스마트폰 위의 딥러닝스마트폰 위의 딥러닝
스마트폰 위의 딥러닝NAVER Engineering
 
ICIP 2018 REVIEW
ICIP 2018 REVIEWICIP 2018 REVIEW
ICIP 2018 REVIEWSungMan Cho
 
[PR12] PR-026: Notes for CVPR Machine Learning Sessions
[PR12] PR-026: Notes for CVPR Machine Learning Sessions[PR12] PR-026: Notes for CVPR Machine Learning Sessions
[PR12] PR-026: Notes for CVPR Machine Learning SessionsTaegyun Jeon
 
LINC3.0 캡스톤디자인 경진대회_로운팀.pptx
LINC3.0 캡스톤디자인 경진대회_로운팀.pptxLINC3.0 캡스톤디자인 경진대회_로운팀.pptx
LINC3.0 캡스톤디자인 경진대회_로운팀.pptxssuser20022f
 
Auto Scalable 한 Deep Learning Production 을 위한 AI Serving Infra 구성 및 AI DevOps...
Auto Scalable 한 Deep Learning Production 을 위한 AI Serving Infra 구성 및 AI DevOps...Auto Scalable 한 Deep Learning Production 을 위한 AI Serving Infra 구성 및 AI DevOps...
Auto Scalable 한 Deep Learning Production 을 위한 AI Serving Infra 구성 및 AI DevOps...hoondong kim
 
“머신러닝 엔지니어가 다녀온 F8” 김준성 - F8 2019 Meetup:Seoul
“머신러닝 엔지니어가 다녀온 F8” 김준성 - F8 2019 Meetup:Seoul“머신러닝 엔지니어가 다녀온 F8” 김준성 - F8 2019 Meetup:Seoul
“머신러닝 엔지니어가 다녀온 F8” 김준성 - F8 2019 Meetup:SeoulJunseong Kim
 
Convolutional Neural Networks
Convolutional Neural NetworksConvolutional Neural Networks
Convolutional Neural NetworksSanghoon Yoon
 
소프트웨어 중심 시대를 준비하자
소프트웨어 중심 시대를 준비하자소프트웨어 중심 시대를 준비하자
소프트웨어 중심 시대를 준비하자Deogtae Kim
 
CNN Architecture A to Z
CNN Architecture A to ZCNN Architecture A to Z
CNN Architecture A to ZLEE HOSEONG
 
머신러닝 및 데이터 과학 연구자를 위한 python 기반 컨테이너 분산처리 플랫폼 설계 및 개발
머신러닝 및 데이터 과학 연구자를 위한 python 기반 컨테이너 분산처리 플랫폼 설계 및 개발머신러닝 및 데이터 과학 연구자를 위한 python 기반 컨테이너 분산처리 플랫폼 설계 및 개발
머신러닝 및 데이터 과학 연구자를 위한 python 기반 컨테이너 분산처리 플랫폼 설계 및 개발Jeongkyu Shin
 
클로져 소개 강의 (한국정보통신산업노동조합)
클로져 소개 강의 (한국정보통신산업노동조합)클로져 소개 강의 (한국정보통신산업노동조합)
클로져 소개 강의 (한국정보통신산업노동조합)Sang-Kyu Park
 
딥러닝 세계에 입문하기 위반 분투
딥러닝 세계에 입문하기 위반 분투딥러닝 세계에 입문하기 위반 분투
딥러닝 세계에 입문하기 위반 분투Ubuntu Korea Community
 
Deep neural networks cnn rnn_ae_some practical techniques
Deep neural networks cnn rnn_ae_some practical techniquesDeep neural networks cnn rnn_ae_some practical techniques
Deep neural networks cnn rnn_ae_some practical techniquesKang Pilsung
 
Image Deep Learning 실무적용
Image Deep Learning 실무적용Image Deep Learning 실무적용
Image Deep Learning 실무적용Youngjae Kim
 
스프링보다 중요한 스프링 이야기
스프링보다 중요한 스프링 이야기스프링보다 중요한 스프링 이야기
스프링보다 중요한 스프링 이야기Sungchul Park
 
회사에서 새로운 기술_적용하기
회사에서 새로운 기술_적용하기회사에서 새로운 기술_적용하기
회사에서 새로운 기술_적용하기Dexter Jung
 
[강의] OOP 개요
[강의] OOP 개요[강의] OOP 개요
[강의] OOP 개요Nohyun Kee
 
Javascript everywhere - Node.js | Devon 2012
Javascript everywhere - Node.js | Devon 2012Javascript everywhere - Node.js | Devon 2012
Javascript everywhere - Node.js | Devon 2012Daum DNA
 
2012 3 qp_hybrid algorithm optimization with artificial intelligence
2012 3 qp_hybrid algorithm optimization with artificial intelligence 2012 3 qp_hybrid algorithm optimization with artificial intelligence
2012 3 qp_hybrid algorithm optimization with artificial intelligence Jong MIn Yu
 

Ähnlich wie 180525 mobile visionnet_hanlim_extended (20)

스마트폰 위의 딥러닝
스마트폰 위의 딥러닝스마트폰 위의 딥러닝
스마트폰 위의 딥러닝
 
ICIP 2018 REVIEW
ICIP 2018 REVIEWICIP 2018 REVIEW
ICIP 2018 REVIEW
 
[PR12] PR-026: Notes for CVPR Machine Learning Sessions
[PR12] PR-026: Notes for CVPR Machine Learning Sessions[PR12] PR-026: Notes for CVPR Machine Learning Sessions
[PR12] PR-026: Notes for CVPR Machine Learning Sessions
 
LINC3.0 캡스톤디자인 경진대회_로운팀.pptx
LINC3.0 캡스톤디자인 경진대회_로운팀.pptxLINC3.0 캡스톤디자인 경진대회_로운팀.pptx
LINC3.0 캡스톤디자인 경진대회_로운팀.pptx
 
Auto Scalable 한 Deep Learning Production 을 위한 AI Serving Infra 구성 및 AI DevOps...
Auto Scalable 한 Deep Learning Production 을 위한 AI Serving Infra 구성 및 AI DevOps...Auto Scalable 한 Deep Learning Production 을 위한 AI Serving Infra 구성 및 AI DevOps...
Auto Scalable 한 Deep Learning Production 을 위한 AI Serving Infra 구성 및 AI DevOps...
 
“머신러닝 엔지니어가 다녀온 F8” 김준성 - F8 2019 Meetup:Seoul
“머신러닝 엔지니어가 다녀온 F8” 김준성 - F8 2019 Meetup:Seoul“머신러닝 엔지니어가 다녀온 F8” 김준성 - F8 2019 Meetup:Seoul
“머신러닝 엔지니어가 다녀온 F8” 김준성 - F8 2019 Meetup:Seoul
 
Convolutional Neural Networks
Convolutional Neural NetworksConvolutional Neural Networks
Convolutional Neural Networks
 
소프트웨어 중심 시대를 준비하자
소프트웨어 중심 시대를 준비하자소프트웨어 중심 시대를 준비하자
소프트웨어 중심 시대를 준비하자
 
인공지능의 파도가 온다
인공지능의 파도가 온다인공지능의 파도가 온다
인공지능의 파도가 온다
 
CNN Architecture A to Z
CNN Architecture A to ZCNN Architecture A to Z
CNN Architecture A to Z
 
머신러닝 및 데이터 과학 연구자를 위한 python 기반 컨테이너 분산처리 플랫폼 설계 및 개발
머신러닝 및 데이터 과학 연구자를 위한 python 기반 컨테이너 분산처리 플랫폼 설계 및 개발머신러닝 및 데이터 과학 연구자를 위한 python 기반 컨테이너 분산처리 플랫폼 설계 및 개발
머신러닝 및 데이터 과학 연구자를 위한 python 기반 컨테이너 분산처리 플랫폼 설계 및 개발
 
클로져 소개 강의 (한국정보통신산업노동조합)
클로져 소개 강의 (한국정보통신산업노동조합)클로져 소개 강의 (한국정보통신산업노동조합)
클로져 소개 강의 (한국정보통신산업노동조합)
 
딥러닝 세계에 입문하기 위반 분투
딥러닝 세계에 입문하기 위반 분투딥러닝 세계에 입문하기 위반 분투
딥러닝 세계에 입문하기 위반 분투
 
Deep neural networks cnn rnn_ae_some practical techniques
Deep neural networks cnn rnn_ae_some practical techniquesDeep neural networks cnn rnn_ae_some practical techniques
Deep neural networks cnn rnn_ae_some practical techniques
 
Image Deep Learning 실무적용
Image Deep Learning 실무적용Image Deep Learning 실무적용
Image Deep Learning 실무적용
 
스프링보다 중요한 스프링 이야기
스프링보다 중요한 스프링 이야기스프링보다 중요한 스프링 이야기
스프링보다 중요한 스프링 이야기
 
회사에서 새로운 기술_적용하기
회사에서 새로운 기술_적용하기회사에서 새로운 기술_적용하기
회사에서 새로운 기술_적용하기
 
[강의] OOP 개요
[강의] OOP 개요[강의] OOP 개요
[강의] OOP 개요
 
Javascript everywhere - Node.js | Devon 2012
Javascript everywhere - Node.js | Devon 2012Javascript everywhere - Node.js | Devon 2012
Javascript everywhere - Node.js | Devon 2012
 
2012 3 qp_hybrid algorithm optimization with artificial intelligence
2012 3 qp_hybrid algorithm optimization with artificial intelligence 2012 3 qp_hybrid algorithm optimization with artificial intelligence
2012 3 qp_hybrid algorithm optimization with artificial intelligence
 

Mehr von Jaewook. Kang

190111 tf2 preview_jwkang_pub
190111 tf2 preview_jwkang_pub190111 tf2 preview_jwkang_pub
190111 tf2 preview_jwkang_pubJaewook. Kang
 
Cloud tpu jae_180814
Cloud tpu jae_180814Cloud tpu jae_180814
Cloud tpu jae_180814Jaewook. Kang
 
A Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB SimulinkA Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB SimulinkJaewook. Kang
 
A Simple Communication System Design Lab #3 with MATLAB Simulink
A Simple Communication System Design Lab #3 with MATLAB SimulinkA Simple Communication System Design Lab #3 with MATLAB Simulink
A Simple Communication System Design Lab #3 with MATLAB SimulinkJaewook. Kang
 
A Simple Communication System Design Lab #2 with MATLAB Simulink
A Simple Communication System Design Lab #2 with MATLAB SimulinkA Simple Communication System Design Lab #2 with MATLAB Simulink
A Simple Communication System Design Lab #2 with MATLAB SimulinkJaewook. Kang
 
A Simple Communication System Design Lab #1 with MATLAB Simulink
A Simple Communication System Design Lab #1 with MATLAB Simulink A Simple Communication System Design Lab #1 with MATLAB Simulink
A Simple Communication System Design Lab #1 with MATLAB Simulink Jaewook. Kang
 
Jaewook Kang's Phd final defense @ 20151117
Jaewook Kang's  Phd final defense @ 20151117Jaewook Kang's  Phd final defense @ 20151117
Jaewook Kang's Phd final defense @ 20151117Jaewook. Kang
 
Introduction to Soundlly 2nd screen services and technology: Seminar in 금오공대 ...
Introduction to Soundlly 2nd screen services and technology: Seminar in 금오공대 ...Introduction to Soundlly 2nd screen services and technology: Seminar in 금오공대 ...
Introduction to Soundlly 2nd screen services and technology: Seminar in 금오공대 ...Jaewook. Kang
 

Mehr von Jaewook. Kang (9)

190111 tf2 preview_jwkang_pub
190111 tf2 preview_jwkang_pub190111 tf2 preview_jwkang_pub
190111 tf2 preview_jwkang_pub
 
Cloud tpu jae_180814
Cloud tpu jae_180814Cloud tpu jae_180814
Cloud tpu jae_180814
 
Life is stair-like
Life is stair-likeLife is stair-like
Life is stair-like
 
A Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB SimulinkA Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB Simulink
 
A Simple Communication System Design Lab #3 with MATLAB Simulink
A Simple Communication System Design Lab #3 with MATLAB SimulinkA Simple Communication System Design Lab #3 with MATLAB Simulink
A Simple Communication System Design Lab #3 with MATLAB Simulink
 
A Simple Communication System Design Lab #2 with MATLAB Simulink
A Simple Communication System Design Lab #2 with MATLAB SimulinkA Simple Communication System Design Lab #2 with MATLAB Simulink
A Simple Communication System Design Lab #2 with MATLAB Simulink
 
A Simple Communication System Design Lab #1 with MATLAB Simulink
A Simple Communication System Design Lab #1 with MATLAB Simulink A Simple Communication System Design Lab #1 with MATLAB Simulink
A Simple Communication System Design Lab #1 with MATLAB Simulink
 
Jaewook Kang's Phd final defense @ 20151117
Jaewook Kang's  Phd final defense @ 20151117Jaewook Kang's  Phd final defense @ 20151117
Jaewook Kang's Phd final defense @ 20151117
 
Introduction to Soundlly 2nd screen services and technology: Seminar in 금오공대 ...
Introduction to Soundlly 2nd screen services and technology: Seminar in 금오공대 ...Introduction to Soundlly 2nd screen services and technology: Seminar in 금오공대 ...
Introduction to Soundlly 2nd screen services and technology: Seminar in 금오공대 ...
 

Kürzlich hochgeladen

데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법JMP Korea
 
JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!JMP Korea
 
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개JMP Korea
 
JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례JMP Korea
 
공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화JMP Korea
 
JMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement MethodologyJMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement MethodologyJMP Korea
 
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?Jay Park
 
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석JMP Korea
 

Kürzlich hochgeladen (8)

데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법
 
JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!
 
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
 
JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례
 
공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화
 
JMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement MethodologyJMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
 
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
 
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
 

180525 mobile visionnet_hanlim_extended

  • 1. 누구나 TensorFlow! J. Kang Ph.D. Mobile Vision Learning TensorflowLite, Convolutional neural networks, and Mobilenet v1 Jaewook Kang, Ph.D. jwkang10@gmail.com May. 2018 1 © 2018 MoT Lab All Rights Reserved
  • 2. 누구나 TensorFlow! J. Kang Ph.D.  GIST EEC Ph.D. (2015)  신호처리 과학자, 삽질러  모두의 연구소 MoT 연구실 리더  https://www.facebook.com/jwkkang  좋아하는 것:  통계적 신호처리 / 무선통신 신호처리  C++ Native 라이브러리 구현  Mobile Machine learning  수영 덕력 6년 2  대표논문: Jaewook Kang, et al., "Bayesian Hypothesis Test using Nonparametric Belief Propagation for Noisy Sparse Recovery," IEEE Trans. on Signal process., Feb. 2015 Jaewook Kang et al., "Fast Signal Separation of 2D Sparse Mixture via Approximate Message- Passing," IEEE Signal Processing Letters, Nov. 2015 Jaewook Kang (강재욱) 소 개
  • 3. 누구나 TensorFlow! J. Kang Ph.D. 1. 모바일에서 머신러닝을 한다는것 - Why on-device ML? - 해결해줘야 하는 부분 3
  • 4. 누구나 TensorFlow! J. Kang Ph.D. 모바일 머신러닝 Why on-device ML? – Cloud ML의 제약 • UX 측면 4
  • 5. 누구나 TensorFlow! J. Kang Ph.D. 모바일 머신러닝 Why on-device ML? – Cloud ML의 제약 • UX 측면 – 서비스 반응 속도= » 입력 데이터 업로드시간 » +클라우드 Inference 시간 » +결과 다운로드 시간 5
  • 6. 누구나 TensorFlow! J. Kang Ph.D. 모바일 머신러닝 Why on-device ML? – Cloud ML의 제약 • UX 측면 – 서비스 반응 속도 – 오프라인 상황 6
  • 7. 누구나 TensorFlow! J. Kang Ph.D. 모바일 머신러닝 Why on-device ML? – Cloud ML의 제약 • 데이터 소모 측면 – Inference할때마다 » server call 필요 » 입력데이터 업로드 필요 – 큰 데이터 소비 APP  순삭 ㅠ 7
  • 8. 누구나 TensorFlow! J. Kang Ph.D. 모바일 머신러닝 Why on-device ML? – Cloud ML의 제약 • 프라이버시 측면 – 개인화   프라이버시 – 개인화 서비스는 받고 싶은데 내데이터를 주는 건 싫다? • 데이터 퓨젼의 어려움 – 한 클라우드 서비스에서 다양한 개인정보를 수집하기 어려움 » 모바일: 위치정보 / 사진 / 영상 /오디오 8
  • 9. 누구나 TensorFlow! J. Kang Ph.D. 모바일 머신러닝 해결해줘야 하는 부분 – UX + 비용 측면  On-device inference • 반응 속도 (Fast Response) • 배터리 (Efficient Computation) • 모델 사이즈 • 메모리 제한? – 프라이버시 측면 On-device training • 다른 사람 말고 내 얼굴을 잘 인식해라 이놈아 • Transfer learning? • Personal Data fusion 9
  • 10. 누구나 TensorFlow! J. Kang Ph.D. 모바일 머신러닝 해결해줘야 하는 부분 – UX + 비용 측면  On-device inference • 반응 속도 (Fast Response) • 배터리 (Efficient Computation) • 모델 사이즈 • 메모리 제한? – 프라이버시 측면 On-device training • 다른 사람 말고 내 얼굴을 잘 인식해라 이놈아 • Transfer learning? • Personal Data fusion 10
  • 11. 누구나 TensorFlow! J. Kang Ph.D. 모바일 머신러닝 11 - 하이퍼커넥트 신범준님 발표자료 중 -
  • 12. 누구나 TensorFlow! J. Kang Ph.D. Google’s Big Picture – Google’s Approach in Mobile ML env. (utblink)  Pre-training model in cloud  Local fine-Tuning with private data in mobile APP  Run prediction engine in mobile APP  Do the same things in IoT 모바일 머신러닝 12 + NN API +
  • 13. 누구나 TensorFlow! J. Kang Ph.D. Google’s Big Picture – Google’s Approach in Mobile ML env. (utblink)  Pre-training model in cloud  Local fine-Tuning with private data in mobile APP  Run prediction engine in mobile APP  Do the same things in IoT 모바일 머신러닝 13 + NN API + (2016) (2015) (2018) (2017) (2017)
  • 14. 누구나 TensorFlow! J. Kang Ph.D. About ❖A lightweight ML library and tool or mobile devices – https://www.tensorflow.org/mobile/tflite/ – 지원 플랫폼: • Android Mobile • Raspberry Pi 3 (Android Things) • iOS – 지원 ops: Tensorflow >= Tensorflow Lite – 사이즈: Core Interpreter (+supp. Ops) 70kB ( 400kB) – 버전: Developer preview (2017 Nov, w/ TF v1.5) 14
  • 15. 누구나 TensorFlow! J. Kang Ph.D. About 15 이미지 출처: https://www.t ensorflow.org/ mobile/tflite/
  • 16. 누구나 TensorFlow! J. Kang Ph.D. About ❖A lightweight ML library and tool or mobile devices 16 Tflite모델을 각 플랫폼의 커널에서 사용할 수 있도록 번역하는 Api (tflite로딩) 플랫폼 별 tflite 모델을 최적화 용 op set on device HW 계산 자원 할당 최적화 이미지출처: https://www.youtube.com/watch?v=FAMfy7izB6A - Android NNAPI - iOS CoreML- Tensorflow lite framework
  • 17. 누구나 TensorFlow! J. Kang Ph.D. About ❖A lightweight ML library and tool or mobile devices 17 Run on device! Run on device! Run on device! 이미지출처: https://www.youtube.com/watch?v=FAMfy7izB6A - Android NNAPI - iOS CoreML- Tensorflow lite framework
  • 18. 누구나 TensorFlow! J. Kang Ph.D. About ❖A lightweight ML library and tool or mobile devices – iOS develop has another option! – coreML converter 따로 있음: tfcoreml github repo • (tflite+coreml >>10배 속도>> tflite+nnapi) 18 이미지출처: https://www.youtube.com/watch?v=FAMfy7izB6A
  • 19. 누구나 TensorFlow! J. Kang Ph.D. About ❖Why TensorFlow Lite is faster? – FlatBuffer: • A new model file format – Operation kernels optimized for NEON on ARM – Hardware acceleration support • Android NN API (Android Oreo) – Qualcomm Hexagon DSP SDK (Android P) – Direct GPU support • iOS CoreML – Metal2 – Quantization: Integer-arithmetic only support • Quantize both weights and activation as 8-bit integers • Just a few parameters(bias vectors) as 32-bit integers • 가장 범용적인 multiply-add instruction HW에서의 개선 • 용량 줄이기 보다 Inference 속도개선에 집중 19
  • 20. 누구나 TensorFlow! J. Kang Ph.D. Android Neural Network API ❖ Android NN API 개요 – On-deivce에서 계산효율적 ML을 위해서 설계된 Android C/C++ API – TensorFlow Lite 모델은 Android NN API의 Kernel Interpreter로 재구 성 + 최적화 되어 계산 하드웨어에 연결됨. – Hardware-specific processing을 통해서 neural net inference 속도 개 선! • Android 에서 잘 돌아가도록 tflite모델을 재구성 + 계산 자원 분배 • 디바이스가 보유하는 계산 유닛(CPU/CPU/DSP)에 효율적으로 계산 workload를 할당 할 예정 • 현재는 CPU만 지원됨 (2018 Mar) – Supporting Android 8.1 (API level 27 + NDK level 14) or higher • - tflite + nnapi : api level >= 27, ndk level > 14 (neon arm processor 에 최적화) • - tflite only : api level >=21 (안빠름) – tflite는 nnapi가 없어도 돌지만 그 경우 전혀 빠르지 않다! 20 This slide is powered by J. Lee
  • 21. 누구나 TensorFlow! J. Kang Ph.D. Android Neural Network API ❖ Android NN API 개요 – 21 This slide is powered by J. Lee 1) .tflite파일를 JAVA/C++ API 을 통해서 로드해서 2) C++ Android Kernal (Core) Interpreter를 통해서 NNAPI 클래스로 넘겨주고 3) C++ NNAPI Op set을 이용해 서 내부에서 tflite 모델을 low- level로 내부적으로 빌드한다. (최적화) 4) low-level tflite 모델을 NNAPI를 통해서 실행한다.
  • 22. 누구나 TensorFlow! J. Kang Ph.D. 2. Recent Trends of Vision Networks - CNN Concept - Recent Trends 22
  • 23. 누구나 TensorFlow! J. Kang Ph.D. Some References  Standford cs231n 2018 – http://cs231n.stanford.edu 23
  • 24. 누구나 TensorFlow! J. Kang Ph.D. 질문: 계산량이 가장 많고 프라이버시에 민감하며 동시에 정보량이 가장 큰 데이터? 24
  • 25. 누구나 TensorFlow! J. Kang Ph.D. 모바일 머신러닝 계산량이 가장 많고 프라이버시에 민감하며 동시에 정보량이 가장 큰 데이터? 25 이미지출처: http://cs231n.stanford.edu
  • 26. 누구나 TensorFlow! J. Kang Ph.D. 모바일 머신러닝 계산량이 가장 많고 프라이버시에 민감하며 동시에 정보량이 가장 큰 데이터? 26 이미지출처: http://cs231n.stanford.edu
  • 27. 누구나 TensorFlow! J. Kang Ph.D. Convolutional Neural Networks (CNN) Convolutional neural network (CNN) 는 아주 중요하게 되었습니다. – 시각인식 – 신호처리 – 분석 도구 27 이미지출처: http://cs231n.stanford.edu
  • 28. 누구나 TensorFlow! J. Kang Ph.D. CNN을 한마디로 요약하면? Convolutional Neural Networks (CNN) 28 한 layer에 대해서 기존 Fully connected networks 에서 input X과 logit Z 사이의 관계를 “Matrix Multiplication”으로 표현했던 것을 “Convolution”으로 대체하여 표현하여 계산효율성/overfitting을 개선한 networks. 이미지출처: https://www.safaribooksonline.com/library/view/learning-tensorflow/9781491978504/ch04.html Logit: Z Input: X
  • 29. 누구나 TensorFlow! J. Kang Ph.D. CNN is Biologically Inspired! Emerged from the study of the brain’s visual cortex – Visual system의 뉴런은 전체를 보지 않는다! • Retina 뉴런은 제한된 영역의 “local receptive field”를 가진다. • Local receptive field 에서 Edge와 같은 “low-level feature”를 인식한다. 29 이미지출처: https://www.slideshare.net/GauravMittal68/convolutional-neural-networks-cnn
  • 30. 누구나 TensorFlow! J. Kang Ph.D. CNN is Biologically Inspired! Emerged from the study of the brain’s visual cortex – 상위 layer의 뉴런은 에서는 Retina 뉴런에서 인식한 ”Low-level features”를 복합적으로 결합하여 “High-level features”를 구성한다. – High-level feature들은 단계적으로 결합되어 “Entire objects pattern”를 구성하고 뇌에서 인지 한다. 30 이미지출처: https://www.slideshare.net/GauravMittal68/convolutional-neural-networks-cnn Area V1 Area V2 Area V3 Area V4Retina Edges Object parts Entire objects
  • 31. 누구나 TensorFlow! J. Kang Ph.D. CNN을 구성하는 layers – Convolutional layer • Generation of feature map (layer output) • Local feature reception and combination – Pooling layer • Spatial / temporal sub-sampling of features 31
  • 32. 누구나 TensorFlow! J. Kang Ph.D. CNN Basic Architectures Stacking of (Conv layer + pooling layer) – 기본적으로 Conv layer + pool layer를 쌓는 방식 – Output layer 바로 전 몇 단은 FNN을 쌓는다 – Application에 따라서 다양한 configuration이 존재 32
  • 33. 누구나 TensorFlow! J. Kang Ph.D. 모바일 머신러닝 계산량이 가장 많고 프라이버시에 민감하며 동시에 정보량이 가장 큰 데이터? 33 이미지출처: http://cs231n.stanford.edu
  • 34. 누구나 TensorFlow! J. Kang Ph.D. 34 이미지출처: http://cs231n.stanford.edu ImageNet Top-5 error rate
  • 35. 누구나 TensorFlow! J. Kang Ph.D. CNN Benchmark Map  목적: 모바일에도 올릴 수 있는 효율적인 모델을 만들고 싶다! 35 https://www.topbots.com/a-brief-history-of- neural-network-architectures/ Good Region Bad Region
  • 36. 누구나 TensorFlow! J. Kang Ph.D. Comparison to Mobile App Size  대한민국 상위 앱 (안드로이드 기준, 2018 Jan) • 카카오톡: 83.98 MB 네이버: 128 MB • Facebook: 67.97 MB Chrome: 178 MB 36
  • 37. 누구나 TensorFlow! J. Kang Ph.D. 3. Why Depthwise separable convolution? : From Inception to Xception and MobileNet v1 - Szegedy etal, ”Going depper with convolutions,” 2014 - A.G. Howard et al. “MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications”, CoRR, 2017. - F. Chollet, “Xception: Deep Learning with Depthwise Separable Convolution,” 2017 Convolution 연산량과 파라미터 수좀 줄여보자! 37
  • 38. 누구나 TensorFlow! J. Kang Ph.D. How to build model for mobile  목적: 모바일에도 올릴 수 있는 효율적인 CNN 모델을 만들고 싶다! 38 Recent advances are not necessarily making network more efficient with respect to size and speed!!!
  • 39. 누구나 TensorFlow! J. Kang Ph.D. How to build model for mobile  목적: 모바일에도 올릴 수 있는 효율적인 모델을 만들고 싶다! – 방향1: Layer width와 network depth를 무작정 늘리는 것은 우리가 가야 할 방향이 아니다! • Depth : layer의 개수  Ability of object abstraction • Width: 한 layer의 파라미터 개수  Ability of feature abstraction in one layer – 방향2: 모델사이즈와 성능의 trade-off를 쉽게 조절할 수 있는 meta- parameter를 설정해야한다. • 코드에 대한 큰 수정 없이 간단하게 trade-off를 조절할 수 있어야 한다. 39 Recent advances are not necessarily making network more efficient with respect to size and speed!!!
  • 40. 누구나 TensorFlow! J. Kang Ph.D. How to build model for mobile  핵심질문: 계산 복잡도/사이즈를 줄이면서 conv layer의 표현력을 유지 할수 있는가? (효율적인 feature extraction) 40
  • 41. 누구나 TensorFlow! J. Kang Ph.D. How to build model for mobile  핵심질문: 계산 복잡도/사이즈를 줄이면서 conv layer의 표현력을 유지 할수 있는가? (효율적인 feature extraction) – Depthwise separable convolution! 41
  • 42. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution  근데 사실 Mobilenet에 보다 Xception에서 먼저 사용한 용어 – F. Chollet, “Xception: Deep Learning with Depthwise Separable Convolutions,” arXiv: 1610.02357, 2016 – Depthwise separable convolution의 기원을 알고싶은면 봐야한다. 42
  • 43. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Xception  핵심가설: The mapping of “cross-channels correlation” and “spatial correlation” can be entirely decoupled!  무슨 말인가? 43
  • 44. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Xception  핵심가설: The mapping of “cross-channels correlation” and “spatial correlation” can be entirely decoupled!  무슨 말인가? – Cross-channel correlation: conv layer에 입력되는 채널 간의 비슷한 정도 44 High cross-channel correlation!
  • 45. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Xception  핵심가설: The mapping of “cross-channels correlation” and “spatial correlation” can be entirely decoupled!  무슨 말인가? – Cross-channel correlation: conv layer에 입력되는 채널 간의 비슷한 정도 45 Very? Low cross-channel correlation!
  • 46. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Xception  핵심가설: The mapping of “cross-channels correlation” and “spatial correlation” can be entirely decoupled!  무슨 말인가? – Spatial correlation: conv filter와 입력 채널 사이의 상관도 46Conv filter 이미지출처: http://user- image.logdown.io/user/136 73/blog/12890/post/30264 1/V21DnAAeTKiOirZRFKhT_ dl2.png Low correlation High correlation
  • 47. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Xception  핵심가설: The mapping of “cross-channels correlation” and “spatial correlation” can be entirely decoupled!  무슨 말인가? – Spatial correlation: conv filter와 입력 채널 사이의 상관도 – High spatial correlation: 해당 conv filter로 feature extraction이 잘된다. – Low spatial correlation: 해당 conv filter로 feature extraction이 잘 안된다. 47Conv filter
  • 48. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Xception  핵심가설: The mapping of “cross-channels correlation” and “spatial correlation” can be entirely decoupled!  무슨 말인가? – “입력 채널간의 유사도”와 “filter가 채널에서 뽑아내는 spatial feature”간은 상관이 없을 것이라는 가설 – 다시말해서 입력 채널이 어떤 구성으로 들어와도 feature extraction에는 영향이 크지 않을꺼다! – 그러면 filtering을 할때 입력 채널을 묶어서 하지 않아도 되지 않는가?  …… 하는 가설! 48
  • 49. 누구나 TensorFlow! J. Kang Ph.D. Short Note for Inception Module  본 가설은 사실 “Inception”에서 부터 고려됐음 – Ref: Szegedy etal, Going deeper with convolutions, 2014  Cross channel pooling by 1x1 conv (Dimensionality reduction): – 1x1 conv를 통해서 cross channel pooling을 수행하여 3x3, 5x5 conv에서의 연산량을 줄임 – Feature extraction할때 cross channel correlation은 크게 영향이 없으니 1x1 conv로 좀 입력을 압축해서 넣을 수 있지 않나?  Combination of parallel conv paths: – Layer input을 1x1, 3x3, 5x5 conv path로 병렬적으로 처리 한후 concatenation해서 출력 – Spatial correlation은 conv filter사이즈 마다 다르게 추출 될 것이다. 49
  • 50. 누구나 TensorFlow! J. Kang Ph.D. Short Note for Inception Module 50 Dimensionality reduction Capturing correlation From local clusters Inception module v1 이미지 출처: Szegedy etal, Going deeper with convolutions, 2014 Dimensionality reduction
  • 51. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Xception 51 이미지출처: https://arxiv.org/abs/1610.02357
  • 52. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Xception 52 이미지출처: https://arxiv.org/abs/1610.02357
  • 53. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Xception 53 이미지출처: https://arxiv.org/abs/1610.02357
  • 54. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Xception 54 이미지출처: https://arxiv.org/abs/1610.02357
  • 55. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Mobilenet 55 Depthwise separable conv in Mobilenet – Ref.: A.G. Howard et al. “MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications”, CoRR, 2017. Standard conv DW conv
  • 56. 누구나 TensorFlow! J. Kang Ph.D. Xception vs Mobilenet Xception (2016): – Pwise convolution 먼저 – Single Pwise conv + 7 Dwise conv – Optionally 중간에 Relu non-linearity를 둘 수 있음 – Grid (channel) size reduction에 Max-pooling사용 – Shortcut connection사용 Mobilenet (2017): – Dwise convolution 먼저 – Single Dwise conv + Single Pwise conv – 중간 Relu non-linearity 없음 – Grid (channel) size reduction에 stride-2 conv사용 – Meta parameters!  구현이 다르지만 같은 가설에 기반함 56
  • 57. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Mobilenet  핵심질문: 계산 복잡도/사이즈를 줄이면서 conv layer의 표현력을 유지 할수 있는가? – Standard 3D convolution (입력 채널개수가 L개 경우) • Input channel : N x N x L • Filter size (weight) : K x K x L (x M) • Output channel: (N-K)+1 x (N-K)+1 (No zero padding) – 복잡도: • 3D conv 수행 – Conv의 sliding은 2D 방향으로만 – 각 채널의 3D conv결과를 sum-up – N^2 x K^2 x L • 필터 개수: M • Total: – N^2 x K^2 x L x M 57 이미지출처: http://machinethink.net/blog/googles-mobile-net- architecture-on-iphone/ Filter Size : K x K x L (x M) , where K=3, L=3
  • 58. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Mobilenet  핵심질문: 계산 복잡도/사이즈를 줄이면서 conv layer의 표현력을 유지 할수 있는가?  Depthwise separable convolution – 답: 3D conv 필터링 하지말구… Depthwise-separable conv하자! • Step 1) Depthwise conv (Dwise): – 동일 2D conv필터로 L개 입력채널을 각각 필터링 • Step 2) Pointwise conv (Pwise): – Dwise conv 결과에 대해서 1 x 1 x L (x M) conv를 수행 58
  • 59. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Mobilenet  핵심질문: 계산 복잡도를 줄이면서 conv layer의 표현력을 유지 할수 있는가? – Dwise conv + Pwise conv로 분할 계산 (L개 채널입력) • Input channel : N x N x L • Dwise Filter size (weight) : K x K x 1 • Pwise 1x1 filter: 1 x 1 x L X (M) 59 이미지출처: http://machinethink.net/blog/googles-mobile-net- architecture-on-iphone/ Depthwise Conv Pointwise Conv Dwise Filter Size : K x K x 1 (K=3) Pwise Filter Size : 1 x 1 x L (x M) (L=3) +
  • 60. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Mobilenet  핵심질문: 계산 복잡도를 줄이면서 conv layer의 표현력을 유지 할수 있는가? – Dwise conv: • N x N x L  (N-K)+1 x (N-K)+1 x L – Pwise conv: • (N-K)+1 x (N-K)+1 x L  (N-K)+1 x (N-K)+1 x 1 – 복잡도: • Dwise conv: N^2 x K^2 x L • Pwise conv: {(N-K)+1}^2 x L • Total (M 개 필터): – N^2 x K^2 x L + {(N-K)+1}^2 x L x M 60
  • 61. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Mobilenet  복잡도는 얼마나 줄어드는가? (Mult-Adds) – Standard conv: – Depthwise-separable conv (N >> K): – Complexity ratio: – 필터 크기 K가 dominant!, K가 크다  복잡도 크게 개선 – 필터 개수 M가 크다  복잡도 크게 개선 – K=3 인경우 8~9배 절약 61 N2 K2 LM N2 K2 L + N2 LM Mobilenet Standard = N2 K2 L + N2 LM N2 K2 LM = 1 M + 1 K2
  • 62. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Mobilenet  파라미터 수는 얼마나 줄어드는가? (Parameters) – Standard conv: – Depthwise-separable conv: – Parameter number ratio : 62 Mobilenet Standard = (K2 +1)+ (L +1)M (K2 L +1)M K2 <<LM ¾ ®¾¾¾ L +1 K2 L +1 » 1 K2
  • 63. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Mobilenet  모델 복잡도 / 사이즈 정량적 지표!  Case for K=3, N=14, L=512, M=512 – Million Mult-Adds (복잡도*10^-6): • Std conv: • DW conv: –  52/462 = 0.11 ~= 1/9 (=1/K^2) – Million Parameters (파라미터수 *10^-6): • Std conv: • DW conv: – 0.26/2.35 =0.11 ~= 1/9 (=1/K^2) 63 142 ×9×512×512´10-6 = 462.422016 142 ×9×512+142 ×512×512( )´10-6 = 52.283392 (9×512 +1)×512 ´10-6 = 2.359808 (9 +1)+ (512 +1)×512( )´10-6 = 0.262666
  • 64. 누구나 TensorFlow! J. Kang Ph.D. Depthwise separable convolution: Mobilenet  모델 복잡도 / 사이즈 정량적 지표!  Case for K=3, N=14, L=512, M=512 64
  • 65. 누구나 TensorFlow! J. Kang Ph.D. Width / Resolution Multiplier  핵심질문: 모델사이즈를 간단하게 조절하고 싶다!  Width multiplier ( ) – Conv layer 의 입출력 채널 개수(L,M) 를 조절하는 meta parameter – 모델 파라미터 수에 영향 – 연산량에도 영향  Resolution multiplier ( ) – 입력 채널의 사이즈 (N) 을 조절하는 meta parameter – 모델 파라미터 수에 영향 없음 – 연산량에는 영향 65 a Î(0,1] r Î(0,1] ar2 L(N2 K2 +aN2 M)
  • 66. 누구나 TensorFlow! J. Kang Ph.D. Width / Resolution Multiplier  Meta parameter 조절에 따른 ImageNet Top-1 accuracy – 이름: 66 a Î(0,1] r Î(0,1] aMobileNet-rNin (where Nin = 224) With respect to With respect to
  • 67. 누구나 TensorFlow! J. Kang Ph.D. 67 •Mobilenet_quant_v1_224.tflite •테스트 디바이스: Samsung Galaxy S7 (SM-G930L) + Android 7.0 (Nougat) •빌드 환경: • Mac OSX 10.11.6 • bazel Version : 0.7 • Android Studio 3.0 • Android Build Tools Level: 26.1.1 • Android NDK Version: 16.04442984 1.mobilenet_v1_1.0_224 : 67.9 MB, Top-1 Accuracy=70.7, Top-5 Accuracy=89.5 2.mobilenet_quant_v1_224.tflite: 4.3 MB, Top-1 Accuracy=??, Top-5 Accuracy=??
  • 68. 누구나 TensorFlow! J. Kang Ph.D. Efficient grid size reduction with stride 2  핵심질문: Max pooling layer를 두는 것은 정보량을 손실하는 것이기 때문에 모델의 expressiveness를 열화시키지 않나요 ? – 이건 inception v2에서 부터 했던 얘기 • Ref: Szegedy etal, Rethinking the inception Arch. for computer vision – Mobilenet논문에는 이유에 대한 언급이 없음 – 그럼 inception v2으로 한번 돌아가보자! 68
  • 69. 누구나 TensorFlow! J. Kang Ph.D. Efficient grid size reduction with stride 2  Feature map의 grid size (N)를 pooling이 아닌 stride를 이용해서 줄이자! – GoogLeNet에서는 inception module 앞에 max-pooling layer을 삽입하여 grid size을 줄여왔다. •  계산량 감소! 69
  • 70. 누구나 TensorFlow! J. Kang Ph.D. Efficient grid size reduction with stride 2 70
  • 71. 누구나 TensorFlow! J. Kang Ph.D.  Feature map의 grid size (N) 를 pooling이 아닌 stride를 이용해서 줄이자! – GoogLeNet에서는 inception module 앞에 max-pooling layer을 삽입하여 grid size을 줄여왔다.  Pooling은 연산량을 줄일 수 있지만 representational bottleneck을 야기한다.  Pooling layer를 두지 말고 Inception module안의 conv layer의 stride를 사용하여 grid size reduction을 하자!  질문) 이방법이 왜 max-pooing보다 expressiveness를 제한하지 않는가???? 71 Efficient grid size reduction with stride 2
  • 72. 누구나 TensorFlow! J. Kang Ph.D. Efficient grid size reduction with stride 2  Input image: 427x640  output images: 211x317  Filtersize = 7 x 7 – 1) Std conv (stride=1)+ maxpool (tilesize = 7, stride2) – 2) stride 2 conv
  • 73. 누구나 TensorFlow! J. Kang Ph.D. Efficient grid size reduction with stride 2 73  Input image: 427x640  output images: 211x317  Filtersize = 7 x 7 – 1) Std conv (stride=1)+ maxpool (tilesize = 7, stride2) – 2) stride 2 conv Vertical filtering Horizontal filtering Vertical filtering Horizontal filtering
  • 74. 누구나 TensorFlow! J. Kang Ph.D.  질문) 이방법이 왜 max-pooing보다 expressiveness를 제한하지 않는가???? – 가설: • Stride 2 conv: 훈련과정에서 stride-2에 의한 정보손실을 최소화하는 방향으로 filter을 학습 시킬 수 있음 •  Soft downsampling • Max-pooling: 훈련과정에서 pooling에 의한 정보손실을 만회할 수 있는 여지가 없음 •  Hard downsamping 74 Efficient grid size reduction with stride 2
  • 75. 누구나 TensorFlow! J. Kang Ph.D.  Feature map의 grid size (N) 를 pooling이 아닌 stride를 이용해서 줄이자! 75 Pooling and then Inception (GoogLeNet) Stride 2 convolution in Inception (Inception v2- ) Efficient grid size reduction with stride 2 Grid size ½: 35  17
  • 76. 누구나 TensorFlow! J. Kang Ph.D. Mobilenet Architecture 76  Remarks • All layers are followed by batch normalization and ReLu • The first conv layer adopts a standard conv • Use stride-2 conv alternatively • Use FC layer for the classification layer with softmax activation • Use l2 weight decay • Use a RMSprop optimizer
  • 77. 누구나 TensorFlow! J. Kang Ph.D. Accuracy Comparison to others (1/2) 77 Squeezenet과 비슷한 모델사이즈로 비교
  • 78. 누구나 TensorFlow! J. Kang Ph.D. Accuracy Comparison to others (2/2) 78
  • 79. 누구나 TensorFlow! J. Kang Ph.D. Keys for success of Mobilenet v1  Depthwise-separable-convolution to reduce complexity of convolution layers  Efficient grid size reduction with stride 2 convolution  Meta parameters to control size and complexity of model – Width multiplier to regulate model size and complexity by controlling I/O channel numbers. – Resolution multiplier to regulate complexity by controlling the size of input channels to each layer. 79
  • 80. 누구나 TensorFlow! J. Kang Ph.D. 모두연 MoT랩 소개 딥러닝을 활용하여 세상을 이롭게 할 IoT/Mobile App 개발에 대한 연구를 같이 해봐요!!  https://www.facebook.com/lab4all/posts/761099760749661  jwkang10@gmail.com 로 메일 Keywords: – Thin CNN Model – Model optimization – Tensorflow + lite – Embedded Sys. (IoT) – Android Mobile/Things 80
  • 81. 누구나 TensorFlow! J. Kang Ph.D. MoT Contributors Jaewook Kang (Soundlly) Joon ho Lee (Neurophet) Yonggeun Lee Jay Lee (KakaoPay) SungJin Lee (DU) Seoyoen Yang (SNU) Taekmin Kim (SNU) Jihwan Lee (SNU) Doyoung Kwak (PU) Yunbum Beak (신호시스템) Joongwon Jwang (위메프) Jeongah Shin (HanyangUniv)
  • 83. 누구나 TensorFlow! J. Kang Ph.D. Google Deep learning Jeju Camp 2018 83 24 accepted from 562 and 50+ countries 경쟁율 1 대 24 MoT에서 3명 참가 ! Seoyoen Yang (SNU) Taekmin Kim (SNU)Jaewook Kang (Soundlly)
  • 85. 누구나 TensorFlow! J. Kang Ph.D. 85 The End Mobile Vision Learning 2018 - All right reserved @ Jaewook Kang 2018