95
[email protected] @tommasogritti

Deep learning neural networks and AI explained

Embed Size (px)

Citation preview

Page 1: Deep learning neural networks and AI explained

[email protected]

@tommasogritti

Page 2: Deep learning neural networks and AI explained

Deep Neural Network intuition

Embeddings

Transfer Learning

Tips

Outline

Page 3: Deep learning neural networks and AI explained

Deep Neural Network omnipresence

https://trends.google.com/trends/explore?date=2008-03-09%202017-04-09&q=artificial%20intelligence,machine%20learning,deep%20learning

Page 4: Deep learning neural networks and AI explained

Deep Neural Network omnipresence

https://trends.google.com/trends/explore?date=2008-03-09%202017-04-09&q=artificial%20intelligence,machine%20learning,deep%20learning

Page 5: Deep learning neural networks and AI explained

Deep Neural Network omnipresence

https://trends.google.com/trends/explore?date=2008-03-09%202017-04-09&q=artificial%20intelligence,machine%20learning,deep%20learning

Page 6: Deep learning neural networks and AI explained

Deep Neural Network omnipresence

https://trends.google.com/trends/explore?date=2008-03-09%202017-04-09&q=artificial%20intelligence,machine%20learning,deep%20learning

Page 7: Deep learning neural networks and AI explained

… or almost

https://trends.google.com/trends/explore?date=2008-03-09%202017-04-09&q=artificial%20intelligence,machine%20learning,deep%20learning

Page 9: Deep learning neural networks and AI explained

Human1011 neurons 104 synapses per neuron1016 “operations” / sec250 M neurons per mm3 180,000 km of “wires” 25 Watts

Deep Neural Networks sound coolGPU8x1012 operations / sec 500 Watts 5760 (small) cores $2000

Page 10: Deep learning neural networks and AI explained

Toy example

Num website visits

Num page visited

Average time on page

Converted?

1 13 55s 1

2 1 141s 1

1 8 10s 0

3 5 127s 0

2 3 18s 0

Page 11: Deep learning neural networks and AI explained

Toy example

Num website visits

Num page visited

Average time on page

Converted?

1 13 55s 1

2 1 141s 1

1 8 10s 0

3 5 127s 0

2 3 18s 0

“Num website visits” does not seem to influence output

Page 12: Deep learning neural networks and AI explained

Toy example

Num website visits

Num page visited

Average time on page

Converted?

1 13 55s 1

2 1 141s 1

1 8 10s 0

3 5 127s 0

2 3 18s 0

“Num page visited” above 9 seems to be a good threshold, but even when =1 a person can convert ⇒ no simple threshold

Page 13: Deep learning neural networks and AI explained

Toy example

Num website visits

Num page visited

Average time on page

Converted?

1 13 55s 1

2 1 141s 1

1 8 10s 0

3 5 127s 0

2 3 18s 0

“Avg time on page” > 128 seems to be a good threshold, but even when =55 a person can convert ⇒ no simple threshold

Page 14: Deep learning neural networks and AI explained

Toy example

1

13

55

??

Num website visits

Num page visited

Average time on page

User converted?w1=??

w2=??

w3=??

> 0 converted< 0 not converted

multiply

sum

1*w1 + 13*w2 + 55*w3 > 0

Page 15: Deep learning neural networks and AI explained

Toy example

1

13

55

3.58

Num website visits

Num page visited

Average time on page

User converted?-7.04

0.28

0.12

multiply

sum

> 0 ? YES

Page 16: Deep learning neural networks and AI explained

Toy example

3

5

127

-3.76

Num website visits

Num page visited

Average time on page

User converted?

multiply

sum

> 0 ? NO

-7.04

0.28

0.12

Page 17: Deep learning neural networks and AI explained

Toy example

Num website visits

Num page visited

Average time on page

3

5

-7.04

0.28

0.12127

Method #1

Num website visits

Num page visited

Average time on page

3

5

-2.4

0.91

0.013127

Method #2

Num website visits

Num page visited

Average time on page

3

5

-3.9

0.21

0.03127

Method #3

Num website visits

Num page visited

Average time on page

3

5

-1.1

0.83

0.18127

Method #4

Page 18: Deep learning neural networks and AI explained

Toy example

1

13

55

Method #1

Method #2

Method #3

Method #4

Final estimate

Num website visits

Num page visited

Average time on page

Page 19: Deep learning neural networks and AI explained

Toy example

1

13

55

Method #1

Method #2

Method #3

Method #4

Final estimate

Num website visits

Num page visited

Average time on page

input layerhidden layer

output layer

Page 20: Deep learning neural networks and AI explained

Toy example

1

13

55

Method #1

Method #2

Method #3

Method #4

Final estimate

Num website visits

Num page visited

Average time on page

input layerhidden layer

output layer

Deep = lots of hidden layers

Page 21: Deep learning neural networks and AI explained

http://www.asimovinstitute.org/neural-network-zoo/

Lots of configurations

Page 22: Deep learning neural networks and AI explained

Open source toolkits

Page 23: Deep learning neural networks and AI explained

Neural Networks - Take Home Message● Applicable to endless domains: object recognition, medical imaging,

automotive, finance, robotics, natural language processing, translation

systems, speech recognition

● At the simplest levels only a series of nodes doing sums & thresholding

● Lots of variety

● Lots of open source tools

Page 24: Deep learning neural networks and AI explained

Embeddings

Page 25: Deep learning neural networks and AI explained

Context: object recognitionAutomatically classify product images into 1000s

of categories

Dress Boot

Page 26: Deep learning neural networks and AI explained

Image dataset Image Features Classifier

● Edges● Contrast● Local patterns● colors

● Adaboost● SVM● Random

Forests● Neural Network

Image Classifier (old school)

Page 27: Deep learning neural networks and AI explained

0.2-0.30.150.750.11……

0.93

V =

Input Image Feature extraction Image features

Image Features (old school)

Classifier

f(V) > 0

Page 28: Deep learning neural networks and AI explained

Image dataset Image Features Classifier

● Edges● Contrast● Local patterns● colors

● Adaboost● SVM● Random

Forests● Neural Network

10% 45% 45%

Effort (old school)

Page 29: Deep learning neural networks and AI explained

...still in use today

Page 30: Deep learning neural networks and AI explained

DatasetData gathered from 100s of scraped webshops

Page 31: Deep learning neural networks and AI explained

Dataset5 million products, uncategorised

Page 32: Deep learning neural networks and AI explained

Datasetuncategorised

● Keywords filtering

● Visual clustering

● Human inspection

~500 labelled classes~ 1000 images / class

Page 33: Deep learning neural networks and AI explained

Image classifier (the new way)

Deep Convolutional Neural Network (DCNN)~500 labelled classes~1000 images / class

Backpropagation + Gradient descent

Page 34: Deep learning neural networks and AI explained

Image classifier (the new way)

Forward passtraining imagelabel: pans

Page 35: Deep learning neural networks and AI explained

Image classifier (the new way)

Forward passtraining imagelabel: pans

Page 36: Deep learning neural networks and AI explained

Image classifier (the new way)

Forward passtraining imagelabel: pans

Page 37: Deep learning neural networks and AI explained

Image classifier (the new way)

Forward passtraining imagelabel: pans

Page 38: Deep learning neural networks and AI explained

Image classifier (the new way)

Forward passtraining imagelabel: pans

Page 39: Deep learning neural networks and AI explained

Image classifier (the new way)

Forward passtraining imagelabel: pans

Page 40: Deep learning neural networks and AI explained

Image classifier (the new way)

Forward passtraining imagelabel: pans

Page 41: Deep learning neural networks and AI explained

Image classifier (the new way)

Forward passtraining imagelabel: pans

Page 42: Deep learning neural networks and AI explained

Image classifier (the new way)

Forward passtraining imagelabel: pans

predicted label=shoe

Page 43: Deep learning neural networks and AI explained

Image classifier (the new way)

training imagelabel: pans

predicted label=shoe

Backpropagation + Gradient descent

Page 44: Deep learning neural networks and AI explained

Image classifier (the new way)

training imagelabel: pans

predicted label=shoe

Backpropagation + Gradient descent= update weights “towards target”

Page 45: Deep learning neural networks and AI explained

Image classifier (the new way)

Forward pass

Backpropagation + Gradient descent

● Repeat for all training images

● Repeat till stopping criteria

Page 46: Deep learning neural networks and AI explained

Effort (the new way)

50% 50%

~500 labelled classes~1000 images / class Deep Convolutional Neural Network (DCNN)

Page 47: Deep learning neural networks and AI explained

What is going on in the network?

Dress

Page 48: Deep learning neural networks and AI explained

http://vision03.csail.mit.edu/cnn_art/data/single_layer.png

What is going on in the network?

predicted label=pans

Page 49: Deep learning neural networks and AI explained

http://vision03.csail.mit.edu/cnn_art/data/single_layer.png

What is going on in the network?

AbstractImage

“concepts”

Low levelImage

“concepts”

Page 50: Deep learning neural networks and AI explained

Embedding = self-learnt descriptors

Abstract level concept / descriptor

Dress

0.2-0.30.150.750.11……

0.93

Page 51: Deep learning neural networks and AI explained

Distance in embedding space

E(a), E(b), E(c)

a

b

c

d ( , ) >> d ( , )E(a) E(b) E(c) E(b)

Page 52: Deep learning neural networks and AI explained

Distance in embedding space

Page 53: Deep learning neural networks and AI explained

Bracelets (unsorted)

Page 54: Deep learning neural networks and AI explained

Bracelets (sorted on embedding)

Page 55: Deep learning neural networks and AI explained

Bracelets (sorted on embedding)

Page 56: Deep learning neural networks and AI explained

Shoes (unsorted)

Page 57: Deep learning neural networks and AI explained

Shoes (sorted on embedding)

Page 58: Deep learning neural networks and AI explained

Shoes (sorted on embedding)

Page 59: Deep learning neural networks and AI explained

Iterative refinementNewly discovered

classesRe-train classifier Results

95% from 5M products classified with confidence > 96%

More than 250 new labeled categories

Page 60: Deep learning neural networks and AI explained

Context: identity recognitionAutomatically recognize celebrities from

red carpet events

Jennifer Aniston

LL Cool J

Page 61: Deep learning neural networks and AI explained

Embedding training

Triplet Loss

Train network to discriminate between triplets of images

Triplets

Page 62: Deep learning neural networks and AI explained

Training

Random embedding initialization

Embedding training

Trained embedding

Page 63: Deep learning neural networks and AI explained

Celebrity identifier

Page 64: Deep learning neural networks and AI explained

Celebrity identifier

Page 65: Deep learning neural networks and AI explained

Celebrity identifier

Page 66: Deep learning neural networks and AI explained

Celebrity identifier

Page 67: Deep learning neural networks and AI explained

Celebrity identifier

Page 68: Deep learning neural networks and AI explained

NLP - Word embeddings

https://medium.com/@ageitgey/machine-learning-is-fun-part-5-language-translation-with-deep-learning-and-the-magic-of-sequences-2ace0acca0aa

With a different network setup we can learn an embedding for words:

Page 69: Deep learning neural networks and AI explained

NLP - Word embeddings

Each word is represented by a vector. Vector allow to explore very

interesting relationships learnt automatically from the data:

● King - man + woman → queen

● Paris - France + Italy → Rome

● Obama - USA + Russia → Putin

● President - power → prime minister

Page 70: Deep learning neural networks and AI explained

Embeddings - Take Home Message● From feature engineering to data collection

● Neural Networks automatically learn relevant high level

abstractions

● Embedding spaces very useful to explore data

● Application areas: retrieval or ranking tasks (e.g. product

recommendation, customer segmentation), classification

Page 71: Deep learning neural networks and AI explained

Transfer learning

Page 72: Deep learning neural networks and AI explained

ImageNet

1.5 million training examples

1000 categories

Training time ~ days on best GPUs

Page 73: Deep learning neural networks and AI explained

Transfer Learningrandomly initialized

weightsImageNet

Page 74: Deep learning neural networks and AI explained

Transfer Learningrandomly initialized

weightsImageNet Network trained to

classify 1000 classes

Classify correctly (>90%) images in

1000 classes

Page 75: Deep learning neural networks and AI explained

Transfer LearningNew data

New classes

?

Page 76: Deep learning neural networks and AI explained

Transfer Learningrandomly initialized

weightsImageNet Network trained to

classify 1000 classesFine-tune model(update weights)

New dataNew classes

Page 77: Deep learning neural networks and AI explained

Transfer Learningrandomly initialized

weightsImageNet Network trained to

classify 1000 classesFine-tune model(update weights)

New dataNew classes● Faster training time

● Better performance

Page 78: Deep learning neural networks and AI explained

Sharing pre-trained models● Model-Zoo:

https://github.com/BVLC/caffe/wiki/Model-Zoo

● Common format to share pre-trained models

● Active discussion and contributions

Page 79: Deep learning neural networks and AI explained

Sharing pre-trained models

Page 80: Deep learning neural networks and AI explained

Transfer Learning - recommendations

small; similar

large; similar

small; different

large; different

Similarity of the data

Size

of d

atab

ase

Page 81: Deep learning neural networks and AI explained

Transfer Learning - recommendations

Small; similar

large; similar

small; different

large; different

Use existing embedding

Similarity of the data

Size

of d

atab

ase

Page 82: Deep learning neural networks and AI explained

Transfer Learning - recommendations

Small; similar

large; similar

small; different

large; different

Use existing embedding

Fine-tune complete network

Similarity of the data

Size

of d

atab

ase

Page 83: Deep learning neural networks and AI explained

Transfer Learning - recommendations

Small; similar

large; similar

small; different

large; different

Use existing embedding

Fine-tune complete network

Use activations from earlier

in the network

Fine-tune complete network (or start from scratch)

Similarity of the data

Size

of d

atab

ase

Page 84: Deep learning neural networks and AI explained

Transfer Learning - recommendations

Small; similar

large; similar

small; different

large; different

Use existing embedding

Fine-tune complete network

Use activations from earlier

in the network

Fine-tune complete network (or start from scratch)

Similarity of the data

Size

of d

atab

ase

Page 85: Deep learning neural networks and AI explained

Transfer Learning - Take Home Message● Faster progress

● Training also with much smaller amount of data

● Check closest available model before starting from scratch

Page 86: Deep learning neural networks and AI explained

Should we all go

deep?

Page 87: Deep learning neural networks and AI explained

Some questions you should ask● What is the performance of the baseline?

○ What can be achieved with a simpler system?

○ Can we start testing the value proposition with a simpler system?

Page 88: Deep learning neural networks and AI explained

Some questions you should ask● What is the performance of the baseline?

● How much training data is required?

Page 89: Deep learning neural networks and AI explained

Some questions you should ask● What is the performance of the baseline?

● How much training data is required?

● Do we have the data, can we acquire it or how long does it take to collect it?

Page 90: Deep learning neural networks and AI explained

Some questions you should ask● What is the performance of the baseline?

● How much training data is required?

● Do we have the data, can we acquire it or how long does it take to collect it?

● Do we need labeled data or can we use unlabeled data?

Page 91: Deep learning neural networks and AI explained

Some questions you should ask● What is the performance of the baseline?

● How much training data is required?

● Do we have the data, can we acquire it or how long does it take to collect it?

● Do we need labeled data or can we use unlabeled data?

● How well does it work on data it has never seen? Generalization / Overfitting

Page 92: Deep learning neural networks and AI explained

Some questions you should ask● What is the performance of the baseline?

● How much training data is required?

● Do we have the data, can we acquire it or how long does it take to collect it?

● Do we need labeled data or can we use unlabeled data?

● How well does it work on data it has never seen? Generalization / Overfitting

● What are the failure cases?

Page 93: Deep learning neural networks and AI explained

Some questions you should ask● What is the performance of the baseline?

● How much training data is required?

● Do we have the data, can we acquire it or how long does it take to collect it?

● Do we need labeled data or can we use unlabeled data?

● How well does it work on data it has never seen? Generalization / Overfitting

● What are the failure cases?

● How reliable is the confidence of the prediction?

Page 94: Deep learning neural networks and AI explained

Some questions you should ask● What is the performance of the baseline?

● How much training data is required?

● Do we have the data, can we acquire it or how long does it take to collect it?

● Do we need labeled data or can we use unlabeled data?

● How well does it work on data it has never seen? Generalization / Overfitting

● What are the failure cases?

● How reliable is the confidence of the prediction?

● Can we explain why a prediction has been made?

Page 95: Deep learning neural networks and AI explained

[email protected]

@tommasogritti

Thank you!