CS231n Caffe Tutorial

Similar documents
Getting Started with Caffe Julien Demouth, Senior Engineer

Fast R-CNN Object detection with Caffe

Lecture 6: Classification & Localization. boris. ginzburg@intel.com

Fast R-CNN. Author: Ross Girshick Speaker: Charlie Liu Date: Oct, 13 th. Girshick, R. (2015). Fast R-CNN. arxiv preprint arxiv:

Implementation of Neural Networks with Theano.

SIGNAL INTERPRETATION

CS 1699: Intro to Computer Vision. Deep Learning. Prof. Adriana Kovashka University of Pittsburgh December 1, 2015

Advanced analytics at your hands

Supporting Online Material for

The Impact of Big Data on Classic Machine Learning Algorithms. Thomas Jensen, Senior Business Expedia

Machine Learning in Python with scikit-learn. O Reilly Webcast Aug. 2014

Storing Measurement Data

Neural Networks and Support Vector Machines

Programming Exercise 3: Multi-class Classification and Neural Networks

Niche research. Purpose of Niche Research. The original video of this tutorial is available here:

Ibis: Scaling Python Analy=cs on Hadoop and Impala

Convolutional Feature Maps

Implementation of Canny Edge Detector of color images on CELL/B.E. Architecture.

Serializing Data with Protocol Buffers. Vinicius Vielmo Cogo Smalltalks, DI, FC/UL. February 12, 2014.

HPC ABDS: The Case for an Integrating Apache Big Data Stack

Supporting High-Quality Printing in Web Applications with ArcGIS for Server

Publisher 2010 Cheat Sheet

Pseudo code Tutorial and Exercises Teacher s Version

Introduction to Parallel Programming and MapReduce

Large-Scale Web Applications

CREATING A CUBEMAP AND CUBE FACES FOR USE IN PHOENIX RC SCENERY CREATION

Analysis Tools and Libraries for BigData

Introduction to Machine Learning CMU-10701

TDAQ Analytics Dashboard

A Comparison of Programming Languages for Graphical User Interface Programming

Mixing Hadoop and HPC Workloads on Parallel Filesystems

A Performance Evaluation of Open Source Graph Databases. Robert McColl David Ediger Jason Poovey Dan Campbell David A. Bader

dedupe Documentation Release Forest Gregg, Derek Eder, and contributors

Bert Huang Department of Computer Science Virginia Tech

Performance Analysis of Mixed Distributed Filesystem Workloads

CRASH COURSE PYTHON. Het begint met een idee

Analysis Programs DPDAK and DAWN

Apache Thrift and Ruby

BlobSeer: Towards efficient data storage management on large-scale, distributed systems

Easy Map Excel Tool USER GUIDE

Threat intelligence visibility the way forward. Mike Adler, Senior Product Manager Assure Threat Intelligence

Azure Machine Learning, SQL Data Mining and R

fml The SHOGUN Machine Learning Toolbox (and its python interface)

Pedestrian Detection with RCNN

Drawing a histogram using Excel

Data Centers and Cloud Computing

Modifying Colors and Symbols in ArcMap

E27 SPRING 2013 ZUCKER PROJECT 2 PROJECT 2 AUGMENTED REALITY GAMING SYSTEM

Automating Security Testing. Mark Fallon Senior Release Manager Oracle

Integrated Invoicing and Debt Management System for Mac OS X

How to increase Bat Speed & Bat Quickness / Acceleration

Lecture 6: CNNs for Detection, Tracking, and Segmentation Object Detection

Virtual server management: Top tips on managing storage in virtual server environments

Intelligent Heuristic Construction with Active Learning

Coin Flip Questions. Suppose you flip a coin five times and write down the sequence of results, like HHHHH or HTTHT.

Introduction Disks RAID Tertiary storage. Mass Storage. CMSC 412, University of Maryland. Guest lecturer: David Hovemeyer.

Unlocking the True Value of Hadoop with Open Data Science

Microsoft PowerPoint 2010 Templates and Slide Masters (Level 3)

Supporting High-Quality Printing in Web Applications with ArcGIS 10.1 for Server

Scalable Machine Learning - or what to do with all that Big Data infrastructure

Spark: Cluster Computing with Working Sets

Communication Protocol

Silverlight for Windows Embedded Graphics and Rendering Pipeline 1

64 Bits of MapInfo Pro!!! and the next BIG thing. March 2015

Fireworks CS4 Tutorial Part 1: Intro

National Frozen Foods Case Study

Forecasting Trade Direction and Size of Future Contracts Using Deep Belief Network

Quality of Service (QoS) on Netgear switches

Big Data at Spotify. Anders Arpteg, Ph D Analytics Machine Learning, Spotify

Teradata SQL Assistant Version 13.0 (.Net) Enhancements and Differences. Mike Dempsey

Content Author's Reference and Cookbook

Enabling High-Quality Printing in Web Applications with ArcGIS for Server. Craig Williams Scott Moore

CS555: Distributed Systems [Fall 2015] Dept. Of Computer Science, Colorado State University

RAM & ROM Based Digital Design. ECE 152A Winter 2012

CS 378 Big Data Programming. Lecture 9 Complex Writable Types

CURSIVE HANDWRITING. Why teach Cursive Handwriting? There are a number of advantages for teaching a cursive handwriting style:

Migrating to Excel 2010 from Excel Excel - Microsoft Office 1 of 1

InstaNet: Object Classification Applied to Instagram Image Streams

New Features in TerraScan. Arttu Soininen Software developer Terrasolid Ltd

- Easy to insert & delete in O(1) time - Don t need to estimate total memory needed. - Hard to search in less than O(n) time

Syllabus INFO-UB Design and Development of Web and Mobile Applications (Especially for Start Ups)

Ariba Spend Visibility

Syllabus INFO-GB Design and Development of Web and Mobile Applications (Especially for Start Ups)

Scalable Data Analysis in R. Lee E. Edlefsen Chief Scientist UserR! 2011

Practical Data Science with Azure Machine Learning, SQL Data Mining, and R

Create stunning flash movies online in minutes with the easiest flash maker in the world! Try the world's best online flash movie maker.

Computer Vision Technology. Dave Bolme and Steve O Hara

Simplified Machine Learning for CUDA. Umar

Module 5. Deep Convnets for Local Recognition Joost van de Weijer 4 April 2016

Applications of Deep Learning to the GEOINT mission. June 2015

Rational Application Developer Performance Tips Introduction

Analecta Vol. 8, No. 2 ISSN

Big Data with Component Based Software

Conditioning From Gym To Home To Gym

CS 2750 Machine Learning. Lecture 1. Machine Learning. CS 2750 Machine Learning.

Transcription:

CS231n Caffe Tutorial

Outline Caffe walkthrough Finetuning example With demo! Python interface With demo!

Caffe

Most important tip... Don t be afraid to read the code!

Caffe: Main classes SoftmaxLossLayer Blob: Stores data and derivatives (header source) Layer: Transforms bottom blobs to top blobs (header + source) Net: Many layers; computes gradients via forward / backward (header source) Solver: Uses gradients to update weights (header source) W InnerProductLayer data diffs fc1 X data diffs data diffs DataLayer y data diffs

Protocol Buffers Like strongly typed, binary JSON (site) Developed by Google Define message types in.proto file Define messages in.prototxt or.binaryproto files (Caffe also uses.caffemodel) All Caffe messages defined here: This is a very important file!

Prototxt: Define Net

Prototxt: Define Net Layers and Blobs often have same name!

Prototxt: Define Net Layers and Blobs often have same name! Learning rates (weight + bias) Regularization (weight + bias)

Prototxt: Define Net Number of output classes Layers and Blobs often have same name! Learning rates (weight + bias) Regularization (weight + bias)

Prototxt: Define Net Number of output classes Layers and Blobs often have same name! Set these to 0 to freeze a layer Learning rates (weight + bias) Regularization (weight + bias)

Getting data in: DataLayer Reads images and labels from LMDB file Only good for 1-of-k classification Use this if possible (header source proto)

Getting data in: DataLayer layer { name: "data" type: "Data" top: "data" top: "label" include { phase: TRAIN transform_param { mirror: true crop_size: 227 mean_file: "data/ilsvrc12/imagenet_mean.binaryproto" data_param { source: "examples/imagenet/ilsvrc12_train_lmdb" batch_size: 256 backend: LMDB

Getting data in: ImageDataLayer Get images and labels directly from image files No LMDB but probably slower than DataLayer May be faster than DataLayer if reading over network? Try it out and see (header source proto)

Getting data in: WindowDataLayer Read windows from image files and class labels Made for detection (header source proto)

Getting data in: HDF5Layer Reads arbitrary data from HDF5 files Easy to read / write in Python using h5py Good for any task - regression, etc Other DataLayers do prefetching in a separate thread, HDF5Layer does not Can only store float32 and float64 data - no uint8 means image data will be huge Use this if you have to (header source proto)

Getting data in: from memory Manually copy data into the network Slow; don t use this for training Useful for quickly visualizing results Example later

Data augmentation Happens on-the-fly! Random crops Random horizontal flips Subtract mean image See TransformationParameter proto DataLayer, ImageDataLayer, WindowDataLayer NOT HDF5Layer

Finetuning

Basic Recipe 1. Convert data 2. Define net (as prototxt) 3. Define solver (as prototxt) 4. Train (with pretrained weights)

Convert Data DataLayer reading from LMDB is the easiest Create LMDB using convert_imageset Need text file where each line is [path/to/image.jpeg] [label]

Define Net Write a.prototxt file defing a NetParameter If finetuning, copy existing.prototxt file Change data layer Change output layer: name and num_output Reduce batch size if your GPU is small Set blobs_lr to 0 to freeze layers

Define Solver Write a prototxt file defining a SolverParameter If finetuning, copy existing solver.prototxt file Change net to be your net Change snapshot_prefix to your output Reduce base learning rate (divide by 100) Maybe change max_iter and snapshot

Define net: Change layer name Original prototxt: layer { name: "fc7" type: "InnerProduct" inner_product_param { num_output: 4096 [... ReLU, Dropout] layer { name: "fc8" type: "InnerProduct" inner_product_param { num_output: 1000 Pretrained weights: fc7.weight : [values] fc7.bias : [values] fc8.weight : [values] fc8.bias : [values] Modified prototxt: layer { name: "fc7" type: "InnerProduct" inner_product_param { num_output: 4096 [... ReLU, Dropout] layer { name: "my-fc8" type: "InnerProduct" inner_product_param { num_output: 10

Define net: Change layer name Original prototxt: layer { name: "fc7" type: "InnerProduct" inner_product_param { num_output: 4096 [... ReLU, Dropout] layer { name: "fc8" type: "InnerProduct" inner_product_param { num_output: 1000 Same name: weights copied Pretrained weights: fc7.weight : [values] fc7.bias : [values] fc8.weight : [values] fc8.bias : [values] Modified prototxt: layer { name: "fc7" type: "InnerProduct" inner_product_param { num_output: 4096 [... ReLU, Dropout] layer { name: "my-fc8" type: "InnerProduct" inner_product_param { num_output: 10

Define net: Change layer name Original prototxt: layer { name: "fc7" type: "InnerProduct" inner_product_param { num_output: 4096 [... ReLU, Dropout] layer { name: "fc8" type: "InnerProduct" inner_product_param { num_output: 1000 Pretrained weights: fc7.weight : [values] fc7.bias : [values] fc8.weight : [values] fc8.bias : [values] Different name: weights reinitialized Modified prototxt: layer { name: "fc7" type: "InnerProduct" inner_product_param { num_output: 4096 [... ReLU, Dropout] layer { name: "my-fc8" type: "InnerProduct" inner_product_param { num_output: 10

Demo! hopefully it works...

Python interface

Not much documentation... Read the code! Two most important files: caffe/python/caffe/_caffe.cpp: Exports Blob, Layer, Net, and Solver classes caffe/python/caffe/pycaffe.py Adds extra methods to Net class

Python Blobs Exposes data and diffs as numpy arrays Manually feed data to the network by copying to input numpy arrays

Python Layers layer.blobs gives a list of Blobs for parameters of a layer It s possible to define new types of layers in Python, but still experimental (code unit test)

Python Nets Some useful methods: constructors: Initialize Net from model prototxt file and (optionally) weights file forward: run forward pass to compute loss backward: run backward pass to compute derivatives forward_all: Run forward pass, batching if input data is bigger than net batch size forward_backward_all: Run forward and backward passes in batches

Python Solver Can replace caffe train and instead use Solver directly from Python Example in unit test

Net vs Classifier vs Detector? Most important class is Net, but there are others Classifier (code main): Extends Net to perform classification, averaging over 10 image crops Detector (code main): Extends Net to perform R-CNN style detection Don t use these, but read them to see how Net works

Model ensembles No built-in support; do it yourself

Questions?