2. Caffe for Deep Learning
Caffe
Train new model Pre-trained model
2
3. Caffe for Deep Learning
Installation
Caffe can be installed on both CPU only machine, or GPU
machine,
To install it step by step you can follow:
http://mohanadkaleia.com/install-caffe-on-ubuntu-with-no-gpu/
4. Caffe – Build Prediction Model
I. Design a network
II.Train the network
III.Predict new samples
4
5. Caffe – Build the Model
Build a network
Protobuff format: a data structure format that can be used by
Caffe to generate the code of the network
Python layers
C++ layers
6. Caffe – Build the Model
Data types supported by Caffe
Image Data – read raw images
Database – read data from LMDB*
HDF5
Memory Data
https://en.wikipedia.org/wiki/Lightning_Memory-Mapped_Database 6
14. Caffe – Build the Model
2. Protobuff – LOSS Layer
Takes labeled data
The output of
the last layer
Find the loss
for the back-prop
15
15. Caffe – Build the Model
2. Protobuff – graphical generator
16
●
The protobuff text can be converted into a graphical
form that represent the network using netscope:
http://ethereon.github.io/netscope/quickstart.html
●
If you are lazy enough try this one:
http://yanglei.me/gen_proto/
16. Caffe – Build the Model
Layers supported by Caffe
I. Design a network
II.Train the network
III.Predict new samples
17
17. Caffe – Train (Optimize) the net
Caffe Solver
AdaDelta
SGD
AdaGrad
Adam
RMSprop
Nesterov
18. Caffe – Train (Optimize) the net
Caffe Solver – configuration file
19. Caffe – Train (Optimize) the net
Caffe Solver – run the solver
caffe train -solver lenet_solver.prototxt
lenet_10000.caffemodel
lenet_10000.solverstate
20
20. Caffe – Train (Optimize) the net
Caffe Solver – run the solver
caffe train -solver lenet_solver.prototxt
21. Caffe – Build the Model
Layers supported by Caffe
I. Design a network
II.Train the network
III.Predict new samples
22
22. Caffe – Predict / Classify samples
Caffe Classifier
Caffe Classifier
Trained
model
Deploy.prototxt
Image
sample
Class
(output)
Parameters
23. Caffe – Predict / Classify samples
Caffe Classifier
img = cv2.imread(IMAGE_FILE,0)
Define the Classifier object:
net = caffe.Classifier(MODEL_FILE, PRETRAINED_MODEL, caffe.TEST)
Apply forward pass on the network:
res = net.forward(data = img)
24
24. Caffe – Predict / Classify samples
Caffe Classifier
By applying an image of number 9 as an example, the classifier was able
to classify it correctly as we can see from the image below:
25. Caffe – Hands on Tuturial
Step by step tutorial
The full details about this tutorial is available on my website:
http://mohanadkaleia.com/