KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I...

33
KERAS/TENSORFLOW François Fayard BAYNCORE November 29, 2017 PARIS

Transcript of KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I...

Page 1: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

KERAS/TENSORFLOW

François FayardBAYNCORE

November 29, 2017PARIS

Page 2: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

2

Deep LearningThe perceptron

The Mark I Perceptron MachineCornell Aeronautical Laboratory

(1957)

Page 3: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

3

Classifying points in the plane

P = (x1, x2)

Page 4: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

4

The Perceptron

The point P = (x1, x2) will be classified as:

• blue if u⍺(x1, x2) > 0

• red if u⍺(x1, x2) < 0

Page 5: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

5

A Perceptron is a linear classifier

P = (x1, x2)

Page 6: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

6

The loss function for a classifier and a given point

For any given point P = (x1, x2), we define the loss L(⍺, P) by:

Page 7: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

7

The loss function for a classifier

• The loss for a classifier u⍺ is defined as

• We seek for the classifier with the smallest loss

Page 8: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

8

Stochastic Gradient Descent

• To minimize L:

• We start with a random value ⍺

• We compute the gradient of L analytically (backpropagation) using only a random subset of the images (mini batch)

• We update ⍺ by

where η is the learning rate

• We iterate the process until convergence

Page 9: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

9

Introducing Keras

• Keras is an API specification for building Deep Learning models across platforms

Keras API specification

TensorFlow-Keras …Theano-Keras

Page 10: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

10

Installing Keras & TensorFlow

Page 11: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

11

Installing Keras is easy with Intel

Intel Confidential

Page 12: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

12

Training a neural network is easy with Keras

Intel Confidential

Page 13: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

13

Linear classifiers don’t always do the job

P = (x1, x2)

Page 14: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

14

Hidden LAYERSOur first hidden layer

Page 15: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

15

Our first hidden layer

Page 16: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

16

The activation function

Page 17: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

17

Training a neural network is easy with Keras

Page 18: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

18

Deep learning does the job

P = (x1, x2)

Page 19: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

19

MNIST

Page 20: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

20

Reading digits from MNIST

Page 21: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

21

Deep Learning at Bell Labs: Late 80s

Yann Le CunDirector of AI Research

Facebook

Page 22: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

22

Defining the neural network

Page 23: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

23

Defining the neural network

Page 24: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

24

The learning phase

Page 25: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

25

Benchmarks: Intel TensorFlow

Page 26: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

26

The benchmark: AlexNetWon the ImageNet Challenge in 2012. Topology:• 5 convolutional layers• 3 fully connected layers• 60 million parameters, 650 000 neurons

Page 27: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

27

Google TensorFlow performance on AlexNet

0

50

100

150

200

250

300

350

400

Original

Imag

es p

er s

econ

d

Training - Google Inference - Google

Page 28: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

28

Running vTune on Google TensorFlow

Page 29: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

29

Google/Intel TensorFlow performance on AlexNet

0

200

400

600

800

1000

1200

1400

1600

1800

2000

Original

Num

ber o

f im

ages

per

sec

ond

Inference - Google Inference - Intel

0

200

400

600

800

1000

1200

1400

1600

1800

2000

Original

Num

ber o

f im

ages

per

sec

ond

Training - Google Training - Intel

Page 30: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

30

Running vTune on Intel TensorFlow

Page 31: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

31

Take Home Messages

• Starting Deep Learning is easy with Keras

• Keras is better seen as an API. It can be used with different frameworks.

• Use Intel Optimized Python Distribution for better performance

Page 32: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.

Questions

32

Page 33: KERAS/TENSORFLOW - Microsigma · 2018. 2. 5. · Deep Learning The perceptron. The Mark I Perceptron Machine. Cornell Aeronautical Laboratory (1957) 3. Classifying points in the plane.