applying transfer learning in tensorflow

18
Applying Transfer Learning in TensorFlow Scott Thompson Software Engineer @KontorHQ

Upload: scott-thompson

Post on 16-Apr-2017

4.365 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Applying Transfer Learning in TensorFlow

Applying Transfer Learning in TensorFlow

Scott ThompsonSoftware Engineer

@KontorHQ

Page 2: Applying Transfer Learning in TensorFlow

Lessons learned building a visual search and classifier for Gilt

Page 3: Applying Transfer Learning in TensorFlow

A guide for Software Engineers

Page 4: Applying Transfer Learning in TensorFlow

Classification

Men - Short Sleeve Sport Shirts

Men - Long Sleeve Sport Shirts

Men - Activewear - Activewear Tops

Men - Polos

Page 5: Applying Transfer Learning in TensorFlow

Visual Search

Page 6: Applying Transfer Learning in TensorFlow

How to distill the ‘essence’ of an image?

Page 7: Applying Transfer Learning in TensorFlow

Classification

Nearest-Neighbor Search

Men - Short Sleeve Sport Shirts

Men - Long Sleeve Sport Shirts

Page 8: Applying Transfer Learning in TensorFlow

Image Features

Source: http://opencv.org

Edge Detection Color Histogram Pixel Segmentation

Page 9: Applying Transfer Learning in TensorFlow

How to train?

Google Inception-v3

Pre-trained on ImageNethttp://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz

Convolutional Neural Nets

Source: https://research.googleblog.com/2016/03/train-your-own-image-classifier-with.html

Page 10: Applying Transfer Learning in TensorFlow

1,000,000 images, 1,000 categories

Business office Internet site President

Image Source: http://image-net.org/explore

Page 11: Applying Transfer Learning in TensorFlow

Why use a pre-trained model?

It’s faster (it’s pre-trained)

It’s cheaper (no need for GPU farm)

It generalizes (avoid overfitting)

Image Source: http://image-net.org/explore

Page 12: Applying Transfer Learning in TensorFlow

Transfer Learning

Page 13: Applying Transfer Learning in TensorFlow

Source: https://research.googleblog.com/2016/03/train-your-own-image-classifier-with.html

‘Essence’Edge Detector

Shape Detector

Structure of the Network

Page 14: Applying Transfer Learning in TensorFlow

t-SNE plot - CIFAR-10 pool_3 features

t-SNE Code: https://lvdmaaten.github.io/tsne/

Page 15: Applying Transfer Learning in TensorFlow

Output Layer Input LayerSource: https://github.com/sthomp/tensorflow_transfer_cifar10

Page 16: Applying Transfer Learning in TensorFlow

Performance

About 1 second per image

Gilt has ~40,000 images

~12 hours

Embarrassingly Parallel -> Partition across threads / machines

Cache pool_3 features (numpy array)

Page 17: Applying Transfer Learning in TensorFlow

Applying pool_3 featuresNearest Neighbor Search

Brute Force

Cosine Distance

Checkout https://github.com/spotify/annoy

Train a classifier

Nearest Neighbor Classifier

Softmax

Page 18: Applying Transfer Learning in TensorFlow

You don’t need to use TensorFlow for everything

Reading files / Work Queues

Image resizing

Serializing weights