SlideShare a Scribd company logo
1 of 35
Download to read offline
deep learning with c++
an introduction to tiny-dnn
by Taiga Nomi
embedded software engineer, Osaka, Japan
deep learning
Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY
Facial recognition
Image understanding
Finance
Game playing
Translation
Robotics
Drug discovery
Text recognition
Video processing
Text generation
Deep learning
- Learning a complicated function from many data
- Composed of trainable, simple mathematical functions
Input OutputTrainable Building
Blocks
- text
- audio
- image
- video
- ...
- text
- audio
- image
- video
- ...
deep learning framework
A modern deep learning framework for C++ programmers
1400 stars
500 forks
35 contributors
100 clones/day
“A Modern Deep Learning module” by Edgar Riba
“Deep Learning with Quantization for Semantic Saliency Detection” by Yida Wang
https://summerofcode.withgoogle.com/archive/
1.Easy to introduce
2.Simple syntax
3.Extensible backends
1.Easy to introduce
- Just put the following line into your cpp
tiny-dnn is header only - No installation
tiny-dnn is dependency-free - No prerequisites
#include <tiny_dnn/tiny_dnn.h>
1.Easy to introduce
- You can bring Deep Learning to any target you have a C++ compiler
- Officially supported (by CI builds):
- Windows (msvc2013 32/64bit, msvc2015 32/64bit)
- Linux (gcc4.9, clang3.5)
- OSX(LLVM 7.3)
- tiny-dnn might run on other compiler that support C++11
1.Easy to introduce
- Caffe model converter is also available
- TensorFlow converter - coming soon!
- Close the gap between researcher and engineer
1.Easy to introduce
2.Simple syntax
3.Extensible backends
2.Simple syntax
Example: Multi layer perceptron
Caffe prototxt
input: "data"
input_shape {
dim: 1
dim: 1
dim: 1
dim: 20
}
layer {
name: "ip1"
type: "InnerProduct"
inner_product_param {
num_output: 100
}
bottom: "ip1"
top: "ip2"
}
layer {
name: "a1"
type: "TanH"
bottom: "ip1"
top: "ip1"
}
layer {
name: "ip2"
type: "InnerProduct"
inner_product_param {
num_output: 10
}
bottom: "ip1"
top: "out"
}
layer {
name: "a1"
type: "TanH"
bottom: "out"
top: "out"
}
Tensorflow
w1 = tf.Variable(tf.random_normal([10, 100]))
w2 = tf.Variable(tf.random_normal([100, 20]))
b1 = tf.Variable(tf.random_normal([100]))
b2 = tf.Variable(tf.random_normal([20]))
layer1 = tf.add(tf.matmul(x, w1), b1)
layer1 = tf.nn.relu(layer1)
layer2 = tf.add(tf.matmul(x, w2), b2)
layer2 = tf.nn.relu(layer2)
Keras
model = Sequential([
Dense(100, input_dim=10),
Activation('relu'),
Dense(20),
Activation('relu'),
])
tiny-dnn
network<sequential> net;
net << dense<relu>(10, 100)
<< dense<relu>(100, 20);
tiny-dnn, another solution
auto net = make_mlp<relu>({10, 100, 20});
- modern C++ enable us to keep code simple
- type inference, initializer list
2.Simple syntax
Example: Convolutional Neural Networks
Caffe prototxt
name: "LeNet"
layer {
name: "data"
type: "Input"
top: "data"
input_param { shape: { dim: 64
dim: 1 dim: 28 dim: 28 } }
}
layer {
name: "conv1"
type: "Convolution"
bottom: "data"
top: "conv1"
param {
lr_mult: 1
}
param {
lr_mult: 2
}
convolution_param {
num_output: 20
kernel_size: 5
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}
layer {
name: "pool1"
type: "Pooling"
bottom: "conv1"
top: "pool1"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
}
}
layer {
name: "conv2"
type: "Convolution"
bottom: "pool1"
top: "conv2"
param {
lr_mult: 1
}
param {
lr_mult: 2
}
convolution_param {
num_output: 50
kernel_size: 5
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}
layer {
name: "pool2"
type: "Pooling"
bottom: "conv2"
top: "pool2"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
layer {
name: "ip1"
type: "InnerProduct"
bottom: "pool2"
top: "ip1"
param {
param {
lr_mult: 1
}
param {
lr_mult: 2
}
inner_product_param {
num_output: 500
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}
layer {
name: "relu1"
type: "ReLU"
bottom: "ip1"
top: "ip1"
}
layer {
name: "ip2"
type: "InnerProduct"
bottom: "ip1"
top: "ip2"
param {
lr_mult: 1
}
param {
lr_mult: 2
}
inner_product_param {
num_output: 10
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}
}
layer {
name: "relu1"
type: "ReLU"
bottom: "ip1"
top: "ip1"
}
layer {
name: "ip2"
type: "InnerProduct"
bottom: "ip1"
top: "ip2"
param {
lr_mult: 1
}
param {
lr_mult: 2
}
inner_product_param {
num_output: 10
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}
layer {
name: "prob"
type: "Softmax"
bottom: "ip2"
top: "prob"
}
Tensorflow
x = tf.Variable(tf.random_normal([-1, 28, 28, 1]))
wc1 = tf.Variable(tf.random_normal([5, 5, 1, 32]))
wc2 = tf.Variable(tf.random_normal([5, 5, 32, 64]))
wd1 = tf.Variable(tf.random_normal([7*7*64, 1024]))
wout = tf.Variable(tf.random_normal([1024, n_classes]))
bc1 = tf.Variable(tf.random_normal([32]))
bc2 = tf.Variable(tf.random_normal([64]))
bd1 = tf.Variable(tf.random_normal([1024]))
bout = tf.Variable(tf.random_normal([n_classes]))
conv1 = conv2d(x, wc1, bc1)
conv1 = maxpool2d(conv1, k=2)
conv1 = tf.nn.relu(conv1)
conv2 = conv2d(conv1, wc2, bc2)
conv2 = maxpool2d(conv2, k=2)
conv2 = tf.nn.relu(conv2)
fc1 = tf.reshape(conv2, [-1, wd1.get_shape().as_list()[0]])
fc1 = tf.add(tf.matmul(fc1, wd1), bd1)
fc1 = tf.nn.relu(fc1)
fc1 = tf.nn.dropout(fc1, dropout)
out = tf.add(tf.matmul(fc1, wout), bout)
Keras
model = Sequential([
Convolution2D(32, 5, 5, input_shape=[28,28,5]),
MaxPooling2D(pool_size=2),
Activation('relu'),
Convolution2D(64, 5, 5),
MaxPooling2D(pool_size=2),
Activation('relu'),
Dense(1024),
Dropout(0.5),
Dense(10),
])
tiny-dnn
network<sequential> net;
net << conv<>(28, 28, 5, 1, 32)
<< max_pool<relu>(24, 24, 2)
<< conv<>(12, 12, 5, 32, 64)
<< max_pool<relu>(8, 8, 64, 2)
<< fc<relu>(4*4*64, 1024)
<< dropout(1024, 0.5f)
<< fc<>(1024, 10);
1.Easy to introduce
2.Simple syntax
3.Extensible backends
3.Extensible backends
Common scenario1:
“We have a good GPU machine to train networks, but
we need to deploy trained model into mobile device”
Common scenario2:
“We need to write platform-specific code to get
production-level performance... but it’s painful to
understand whole framework”
3.Extensible backends
Some performance critical layers have backend engine
Layer API
backend::internal
pure-c++ code
backend::avx
avx-optimized code …
backend::nnpack
x86/ARM
backend::opencl
GPU
Optional
3.Extensible backends
// select an engine explicitly
net << conv<>(28, 28, 5, 1, 32, backend::avx)
<< ...;
// switch them seamlessly
net[0]->set_backend_type(backend::opencl);
Model serialization (binary/json)
Regression training
Basic image processing
Layer freezing
Graph visualization
Multi-thread execution
Double precision support
Basic functionality
Caffe importer (requires protobuf)
OpenMP support
Intel TBB support
NNPACK backend (same to caffe2)
libdnn backend (same to caffe-opencl)Extra modules
(requires 3rd-party libraries)
Future plans
- GPU integration
- GPU backend is still experimental
- cudnn backend
- More mobile-oriented
- iOS/Android examples
- Quantized operation for less RAM
- TensorFlow Importer
- Performance profiling tools
- OpenVX support
We need your help!
User chat for QA:
https://gitter.im/tiny-dnn
Official documents:
http://tiny-dnn.readthedocs.io/en/latest/
For users
Join our developer chat:
https://gitter.im/tiny-dnn/developers
or
Check out docs, and our issues marked as “contributions welcome”:
https://github.com/tiny-dnn/tiny-dnn/blob/master/docs/developer_gui
des/How-to-contribute.md
https://github.com/tiny-dnn/tiny-dnn/labels/contributions%20welcome
For developers
code: github.com/tiny-dnn/tiny-dnn
slide: https://goo.gl/Se2rzu

More Related Content

What's hot

What's hot (20)

NTU ML TENSORFLOW
NTU ML TENSORFLOWNTU ML TENSORFLOW
NTU ML TENSORFLOW
 
Procedural Art
Procedural ArtProcedural Art
Procedural Art
 
09 Simulation
09 Simulation09 Simulation
09 Simulation
 
Deep Learning and TensorFlow
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlow
 
H2 o berkeleydltf
H2 o berkeleydltfH2 o berkeleydltf
H2 o berkeleydltf
 
Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...
Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...
Sergey Shelpuk & Olha Romaniuk - “Deep learning, Tensorflow, and Fashion: how...
 
Font classification with 5 deep learning models using tensor flow
Font classification with 5 deep learning models using tensor flowFont classification with 5 deep learning models using tensor flow
Font classification with 5 deep learning models using tensor flow
 
Matlab differential
Matlab differentialMatlab differential
Matlab differential
 
Lec 3-mcgregor
Lec 3-mcgregorLec 3-mcgregor
Lec 3-mcgregor
 
Introduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasIntroduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and Keras
 
deep learning library coyoteの開発(CNN編)
deep learning library coyoteの開発(CNN編)deep learning library coyoteの開発(CNN編)
deep learning library coyoteの開発(CNN編)
 
Tutorial 2
Tutorial     2Tutorial     2
Tutorial 2
 
Introduction to Deep Learning, Keras, and Tensorflow
Introduction to Deep Learning, Keras, and TensorflowIntroduction to Deep Learning, Keras, and Tensorflow
Introduction to Deep Learning, Keras, and Tensorflow
 
Alex Smola at AI Frontiers: Scalable Deep Learning Using MXNet
Alex Smola at AI Frontiers: Scalable Deep Learning Using MXNetAlex Smola at AI Frontiers: Scalable Deep Learning Using MXNet
Alex Smola at AI Frontiers: Scalable Deep Learning Using MXNet
 
Computational Linguistics week 10
 Computational Linguistics week 10 Computational Linguistics week 10
Computational Linguistics week 10
 
Survey onhpcs languages
Survey onhpcs languagesSurvey onhpcs languages
Survey onhpcs languages
 
TensorFlow in Your Browser
TensorFlow in Your BrowserTensorFlow in Your Browser
TensorFlow in Your Browser
 
Scaling Deep Learning with MXNet
Scaling Deep Learning with MXNetScaling Deep Learning with MXNet
Scaling Deep Learning with MXNet
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2
 

Similar to Deep learning with C++ - an introduction to tiny-dnn

Building High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortBuilding High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low Effort
Stefan Marr
 
Introduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlowIntroduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlow
Sri Ambati
 
What is the UML Class diagram for accident detection using CNN- i have.pdf
What is the UML Class diagram for accident detection using CNN- i have.pdfWhat is the UML Class diagram for accident detection using CNN- i have.pdf
What is the UML Class diagram for accident detection using CNN- i have.pdf
anilagarwal8880432
 

Similar to Deep learning with C++ - an introduction to tiny-dnn (20)

Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
 
Applied Digital Signal Processing 1st Edition Manolakis Solutions Manual
Applied Digital Signal Processing 1st Edition Manolakis Solutions ManualApplied Digital Signal Processing 1st Edition Manolakis Solutions Manual
Applied Digital Signal Processing 1st Edition Manolakis Solutions Manual
 
Building High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortBuilding High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low Effort
 
Google TensorFlow Tutorial
Google TensorFlow TutorialGoogle TensorFlow Tutorial
Google TensorFlow Tutorial
 
Intro to Deep Learning, TensorFlow, and tensorflow.js
Intro to Deep Learning, TensorFlow, and tensorflow.jsIntro to Deep Learning, TensorFlow, and tensorflow.js
Intro to Deep Learning, TensorFlow, and tensorflow.js
 
RNN sharing at Trend Micro
RNN sharing at Trend MicroRNN sharing at Trend Micro
RNN sharing at Trend Micro
 
Compact and safely: static DSL on Kotlin
Compact and safely: static DSL on KotlinCompact and safely: static DSL on Kotlin
Compact and safely: static DSL on Kotlin
 
Deep Learning in Your Browser
Deep Learning in Your BrowserDeep Learning in Your Browser
Deep Learning in Your Browser
 
Introduction to Deep Learning and TensorFlow
Introduction to Deep Learning and TensorFlowIntroduction to Deep Learning and TensorFlow
Introduction to Deep Learning and TensorFlow
 
Introduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlowIntroduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlow
 
alexnet.pdf
alexnet.pdfalexnet.pdf
alexnet.pdf
 
The best language in the world
The best language in the worldThe best language in the world
The best language in the world
 
Visual Basic(Vb) practical
Visual Basic(Vb) practicalVisual Basic(Vb) practical
Visual Basic(Vb) practical
 
Dsp lab manual
Dsp lab manualDsp lab manual
Dsp lab manual
 
Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...
Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...
Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...
 
What is the UML Class diagram for accident detection using CNN- i have.pdf
What is the UML Class diagram for accident detection using CNN- i have.pdfWhat is the UML Class diagram for accident detection using CNN- i have.pdf
What is the UML Class diagram for accident detection using CNN- i have.pdf
 
Deep Learning, Scala, and Spark
Deep Learning, Scala, and SparkDeep Learning, Scala, and Spark
Deep Learning, Scala, and Spark
 
TensorFlow for IITians
TensorFlow for IITiansTensorFlow for IITians
TensorFlow for IITians
 
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
 
06 Recursion in C.pptx
06 Recursion in C.pptx06 Recursion in C.pptx
06 Recursion in C.pptx
 

Recently uploaded

Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 

Recently uploaded (20)

Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 

Deep learning with C++ - an introduction to tiny-dnn

  • 1. deep learning with c++ an introduction to tiny-dnn by Taiga Nomi embedded software engineer, Osaka, Japan
  • 2. deep learning Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY Facial recognition Image understanding Finance Game playing Translation Robotics Drug discovery Text recognition Video processing Text generation
  • 3. Deep learning - Learning a complicated function from many data - Composed of trainable, simple mathematical functions Input OutputTrainable Building Blocks - text - audio - image - video - ... - text - audio - image - video - ...
  • 5.
  • 6. A modern deep learning framework for C++ programmers
  • 7. 1400 stars 500 forks 35 contributors 100 clones/day
  • 8. “A Modern Deep Learning module” by Edgar Riba “Deep Learning with Quantization for Semantic Saliency Detection” by Yida Wang https://summerofcode.withgoogle.com/archive/
  • 9. 1.Easy to introduce 2.Simple syntax 3.Extensible backends
  • 10. 1.Easy to introduce - Just put the following line into your cpp tiny-dnn is header only - No installation tiny-dnn is dependency-free - No prerequisites #include <tiny_dnn/tiny_dnn.h>
  • 11. 1.Easy to introduce - You can bring Deep Learning to any target you have a C++ compiler - Officially supported (by CI builds): - Windows (msvc2013 32/64bit, msvc2015 32/64bit) - Linux (gcc4.9, clang3.5) - OSX(LLVM 7.3) - tiny-dnn might run on other compiler that support C++11
  • 12. 1.Easy to introduce - Caffe model converter is also available - TensorFlow converter - coming soon! - Close the gap between researcher and engineer
  • 13. 1.Easy to introduce 2.Simple syntax 3.Extensible backends
  • 14. 2.Simple syntax Example: Multi layer perceptron
  • 15. Caffe prototxt input: "data" input_shape { dim: 1 dim: 1 dim: 1 dim: 20 } layer { name: "ip1" type: "InnerProduct" inner_product_param { num_output: 100 } bottom: "ip1" top: "ip2" } layer { name: "a1" type: "TanH" bottom: "ip1" top: "ip1" } layer { name: "ip2" type: "InnerProduct" inner_product_param { num_output: 10 } bottom: "ip1" top: "out" } layer { name: "a1" type: "TanH" bottom: "out" top: "out" }
  • 16. Tensorflow w1 = tf.Variable(tf.random_normal([10, 100])) w2 = tf.Variable(tf.random_normal([100, 20])) b1 = tf.Variable(tf.random_normal([100])) b2 = tf.Variable(tf.random_normal([20])) layer1 = tf.add(tf.matmul(x, w1), b1) layer1 = tf.nn.relu(layer1) layer2 = tf.add(tf.matmul(x, w2), b2) layer2 = tf.nn.relu(layer2)
  • 17. Keras model = Sequential([ Dense(100, input_dim=10), Activation('relu'), Dense(20), Activation('relu'), ])
  • 18. tiny-dnn network<sequential> net; net << dense<relu>(10, 100) << dense<relu>(100, 20);
  • 19. tiny-dnn, another solution auto net = make_mlp<relu>({10, 100, 20}); - modern C++ enable us to keep code simple - type inference, initializer list
  • 21. Caffe prototxt name: "LeNet" layer { name: "data" type: "Input" top: "data" input_param { shape: { dim: 64 dim: 1 dim: 28 dim: 28 } } } layer { name: "conv1" type: "Convolution" bottom: "data" top: "conv1" param { lr_mult: 1 } param { lr_mult: 2 } convolution_param { num_output: 20 kernel_size: 5 stride: 1 weight_filler { type: "xavier" } bias_filler { type: "constant" } } } layer { name: "pool1" type: "Pooling" bottom: "conv1" top: "pool1" pooling_param { pool: MAX kernel_size: 2 stride: 2 } } } } layer { name: "conv2" type: "Convolution" bottom: "pool1" top: "conv2" param { lr_mult: 1 } param { lr_mult: 2 } convolution_param { num_output: 50 kernel_size: 5 stride: 1 weight_filler { type: "xavier" } bias_filler { type: "constant" } } } layer { name: "pool2" type: "Pooling" bottom: "conv2" top: "pool2" pooling_param { pool: MAX kernel_size: 2 stride: 2 } } layer { name: "ip1" type: "InnerProduct" bottom: "pool2" top: "ip1" param { param { lr_mult: 1 } param { lr_mult: 2 } inner_product_param { num_output: 500 weight_filler { type: "xavier" } bias_filler { type: "constant" } } } layer { name: "relu1" type: "ReLU" bottom: "ip1" top: "ip1" } layer { name: "ip2" type: "InnerProduct" bottom: "ip1" top: "ip2" param { lr_mult: 1 } param { lr_mult: 2 } inner_product_param { num_output: 10 weight_filler { type: "xavier" } bias_filler { type: "constant" } } } } layer { name: "relu1" type: "ReLU" bottom: "ip1" top: "ip1" } layer { name: "ip2" type: "InnerProduct" bottom: "ip1" top: "ip2" param { lr_mult: 1 } param { lr_mult: 2 } inner_product_param { num_output: 10 weight_filler { type: "xavier" } bias_filler { type: "constant" } } } layer { name: "prob" type: "Softmax" bottom: "ip2" top: "prob" }
  • 22. Tensorflow x = tf.Variable(tf.random_normal([-1, 28, 28, 1])) wc1 = tf.Variable(tf.random_normal([5, 5, 1, 32])) wc2 = tf.Variable(tf.random_normal([5, 5, 32, 64])) wd1 = tf.Variable(tf.random_normal([7*7*64, 1024])) wout = tf.Variable(tf.random_normal([1024, n_classes])) bc1 = tf.Variable(tf.random_normal([32])) bc2 = tf.Variable(tf.random_normal([64])) bd1 = tf.Variable(tf.random_normal([1024])) bout = tf.Variable(tf.random_normal([n_classes])) conv1 = conv2d(x, wc1, bc1) conv1 = maxpool2d(conv1, k=2) conv1 = tf.nn.relu(conv1) conv2 = conv2d(conv1, wc2, bc2) conv2 = maxpool2d(conv2, k=2) conv2 = tf.nn.relu(conv2) fc1 = tf.reshape(conv2, [-1, wd1.get_shape().as_list()[0]]) fc1 = tf.add(tf.matmul(fc1, wd1), bd1) fc1 = tf.nn.relu(fc1) fc1 = tf.nn.dropout(fc1, dropout) out = tf.add(tf.matmul(fc1, wout), bout)
  • 23. Keras model = Sequential([ Convolution2D(32, 5, 5, input_shape=[28,28,5]), MaxPooling2D(pool_size=2), Activation('relu'), Convolution2D(64, 5, 5), MaxPooling2D(pool_size=2), Activation('relu'), Dense(1024), Dropout(0.5), Dense(10), ])
  • 24. tiny-dnn network<sequential> net; net << conv<>(28, 28, 5, 1, 32) << max_pool<relu>(24, 24, 2) << conv<>(12, 12, 5, 32, 64) << max_pool<relu>(8, 8, 64, 2) << fc<relu>(4*4*64, 1024) << dropout(1024, 0.5f) << fc<>(1024, 10);
  • 25. 1.Easy to introduce 2.Simple syntax 3.Extensible backends
  • 26. 3.Extensible backends Common scenario1: “We have a good GPU machine to train networks, but we need to deploy trained model into mobile device” Common scenario2: “We need to write platform-specific code to get production-level performance... but it’s painful to understand whole framework”
  • 27. 3.Extensible backends Some performance critical layers have backend engine Layer API backend::internal pure-c++ code backend::avx avx-optimized code … backend::nnpack x86/ARM backend::opencl GPU Optional
  • 28. 3.Extensible backends // select an engine explicitly net << conv<>(28, 28, 5, 1, 32, backend::avx) << ...; // switch them seamlessly net[0]->set_backend_type(backend::opencl);
  • 29. Model serialization (binary/json) Regression training Basic image processing Layer freezing Graph visualization Multi-thread execution Double precision support Basic functionality
  • 30. Caffe importer (requires protobuf) OpenMP support Intel TBB support NNPACK backend (same to caffe2) libdnn backend (same to caffe-opencl)Extra modules (requires 3rd-party libraries)
  • 32. - GPU integration - GPU backend is still experimental - cudnn backend - More mobile-oriented - iOS/Android examples - Quantized operation for less RAM - TensorFlow Importer - Performance profiling tools - OpenVX support We need your help!
  • 33. User chat for QA: https://gitter.im/tiny-dnn Official documents: http://tiny-dnn.readthedocs.io/en/latest/ For users
  • 34. Join our developer chat: https://gitter.im/tiny-dnn/developers or Check out docs, and our issues marked as “contributions welcome”: https://github.com/tiny-dnn/tiny-dnn/blob/master/docs/developer_gui des/How-to-contribute.md https://github.com/tiny-dnn/tiny-dnn/labels/contributions%20welcome For developers