Similar documents
Administration. Registration Hw3 is out. Lecture Captioning (Extra-Credit) Scribing lectures. Questions. Due on Thursday 10/6

Neural Networks 2. 2 Receptive fields and dealing with image inputs

Machine Learning. Neural Networks. (slides from Domingos, Pardo, others)

Machine Learning. Neural Networks. (slides from Domingos, Pardo, others)

Lecture 17: Neural Networks and Deep Learning

Need for Deep Networks Perceptron. Can only model linear functions. Kernel Machines. Non-linearity provided by kernels

Introduction to Convolutional Neural Networks (CNNs)

Neural Networks: Introduction

Machine Learning. Neural Networks. (slides from Domingos, Pardo, others)

Machine Learning for Signal Processing Neural Networks Continue. Instructor: Bhiksha Raj Slides by Najim Dehak 1 Dec 2016

CSC 578 Neural Networks and Deep Learning

Multilayer Perceptrons (MLPs)

Data Mining Part 5. Prediction

Need for Deep Networks Perceptron. Can only model linear functions. Kernel Machines. Non-linearity provided by kernels

Artificial Neural Networks D B M G. Data Base and Data Mining Group of Politecnico di Torino. Elena Baralis. Politecnico di Torino

Lecture 6. Notes on Linear Algebra. Perceptron

Neural networks. Chapter 20. Chapter 20 1

Classification goals: Make 1 guess about the label (Top-1 error) Make 5 guesses about the label (Top-5 error) No Bounding Box

Machine Learning Lecture 10

Convolutional Neural Networks. Srikumar Ramalingam

Neural Networks and Deep Learning

Lecture 5 Neural models for NLP

(Feed-Forward) Neural Networks Dr. Hajira Jabeen, Prof. Jens Lehmann

Artificial Neural Networks. Introduction to Computational Neuroscience Tambet Matiisen

Neural networks. Chapter 19, Sections 1 5 1

From perceptrons to word embeddings. Simon Šuster University of Groningen

ARTIFICIAL INTELLIGENCE. Artificial Neural Networks

Neural Networks. Bishop PRML Ch. 5. Alireza Ghane. Feed-forward Networks Network Training Error Backpropagation Applications

Neural Networks. Nicholas Ruozzi University of Texas at Dallas

Lecture 4: Perceptrons and Multilayer Perceptrons

<Special Topics in VLSI> Learning for Deep Neural Networks (Back-propagation)

How to do backpropagation in a brain

CSE446: Neural Networks Spring Many slides are adapted from Carlos Guestrin and Luke Zettlemoyer

DEEP LEARNING AND NEURAL NETWORKS: BACKGROUND AND HISTORY

Machine Learning. Neural Networks

Logistic Regression & Neural Networks

RegML 2018 Class 8 Deep learning

ML4NLP Multiclass Classification

Grundlagen der Künstlichen Intelligenz

Machine Learning Lecture 12

Machine Learning for Large-Scale Data Analysis and Decision Making A. Neural Networks Week #6

Neural Networks. Single-layer neural network. CSE 446: Machine Learning Emily Fox University of Washington March 10, /9/17

Artificial Neural Networks

Lecture 5: Logistic Regression. Neural Networks

Deep Learning Recurrent Networks 2/28/2018

Artificial Neural Networks

Apprentissage, réseaux de neurones et modèles graphiques (RCP209) Neural Networks and Deep Learning

AI Programming CS F-20 Neural Networks

Recurrent Neural Networks

ARTIFICIAL NEURAL NETWORK PART I HANIEH BORHANAZAD

Neural Networks. Chapter 18, Section 7. TB Artificial Intelligence. Slides from AIMA 1/ 21

CSC321 Lecture 16: ResNets and Attention

Artificial Neural Networks" and Nonparametric Methods" CMPSCI 383 Nov 17, 2011!

Neural Networks: Backpropagation

Neural Networks Learning the network: Backprop , Fall 2018 Lecture 4

Neural Networks and Deep Learning.

Dan Roth 461C, 3401 Walnut

Convolutional Neural Networks II. Slides from Dr. Vlad Morariu

SGD and Deep Learning

Neural networks. Chapter 20, Section 5 1

CS249: ADVANCED DATA MINING

Online Videos FERPA. Sign waiver or sit on the sides or in the back. Off camera question time before and after lecture. Questions?

CSCI567 Machine Learning (Fall 2018)

Feed-forward Networks Network Training Error Backpropagation Applications. Neural Networks. Oliver Schulte - CMPT 726. Bishop PRML Ch.

Introduction to Convolutional Neural Networks 2018 / 02 / 23

Introduction to Deep Learning

17 Neural Networks NEURAL NETWORKS. x XOR 1. x Jonathan Richard Shewchuk

Machine learning comes from Bayesian decision theory in statistics. There we want to minimize the expected value of the loss function.

STA 414/2104: Lecture 8

Pattern Recognition Prof. P. S. Sastry Department of Electronics and Communication Engineering Indian Institute of Science, Bangalore

Deep Learning for NLP

Slide credit from Hung-Yi Lee & Richard Socher

Deep Learning Sequence to Sequence models: Attention Models. 17 March 2018

Natural Language Processing with Deep Learning CS224N/Ling284

Long-Short Term Memory and Other Gated RNNs

11/3/15. Deep Learning for NLP. Deep Learning and its Architectures. What is Deep Learning? Advantages of Deep Learning (Part 1)

Recurrent Neural Networks. Jian Tang

Neural networks and optimization

Lecture 15: Exploding and Vanishing Gradients

1 What a Neural Network Computes

Part 8: Neural Networks

Lecture 8: Introduction to Deep Learning: Part 2 (More on backpropagation, and ConvNets)

HISTORY. In the 70 s vs today variants. (Multi-layer) Feed-forward (perceptron) Hebbian Recurrent

NONLINEAR CLASSIFICATION AND REGRESSION. J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

Neural Networks biological neuron artificial neuron 1

Lecture 35: Optimization and Neural Nets

Deep Learning: a gentle introduction

18.6 Regression and Classification with Linear Models

Computational statistics

Deep learning / Ian Goodfellow, Yoshua Bengio and Aaron Courville. - Cambridge, MA ; London, Spis treści

CS 4700: Foundations of Artificial Intelligence

Introduction to Artificial Neural Networks

Neural Networks. Learning and Computer Vision Prof. Olga Veksler CS9840. Lecture 10

Introduction to Deep Neural Networks

Machine Learning for Computer Vision 8. Neural Networks and Deep Learning. Vladimir Golkov Technical University of Munich Computer Vision Group

Artificial Neural Networks. Historical description

Last update: October 26, Neural networks. CMSC 421: Section Dana Nau

Feature Design. Feature Design. Feature Design. & Deep Learning

CS 179: LECTURE 16 MODEL COMPLEXITY, REGULARIZATION, AND CONVOLUTIONAL NETS

STA 414/2104: Lecture 8

Transcription:

CIS 519/419 Applied Machine Learning www.seas.upenn.edu/~cis519 Dan Roth danroth@seas.upenn.edu http://www.cis.upenn.edu/~danroth/ 461C, 3401 Walnut Lecture given by Daniel Khashabi Slides were created by Dan Roth (for CIS519/419 at Penn or CS446 at UIUC), Eric Eaton for CIS519/419 at Penn, or from other authors who have made their ML slides available.

Functions Can be Made Linear Data are not linearly separable in one dimension Not separable if you insist on using a specific class of functions x 2

Blown Up Feature Space Data are separable in <x, x 2 > space x 2 x 3

Multi-Layer Neural Network Multi-layer network were designed to overcome the computational (expressivity) limitation of a single threshold element. The idea is to stack several layers of threshold elements, each layer using the output of the previous layer as input. activation Multi-layer networks can represent arbitrary functions, but building effective learning methods for such network was [thought to be] difficult. Output Hidden Input 4

Basic Units Linear Unit: Multiple layers of linear functions o j = w x produce linear functions. We want to represent nonlinear functions. activation Need to do it in a way that facilitates learning Threshold units: o j = sgn(w x) are not differentiable, hence unsuitable for gradient descent. The key idea was to notice that the discontinuity of the threshold element can be represents by a smooth non-linear approximation: o j = [1+ exp{-w x}] -1 (Rumelhart, Hinton, Williiam, 1986), (Linnainmaa, 1970), see: http://people.idsia.ch/~juergen/whoinvented-backpropagation.html ) w 2 ij Output Hidden w 1 ij Input 5

Model Neuron (Logistic) x 1 x 7 1 2 3 4 5 6 Us a non-linear, differentiable output function such as the sigmoid or logistic function w 17 w 67 7 T T j O j Net input to a unit is defined as: Output of a unit is defined as: O j = 1 + e 1 (net j T net = w j ) j ij x i 6

Learning with a Multi-Layer Perceptron It s easy to learn the top layer it s just a linear unit. Given feedback (truth) at the top layer, and the activation at the layer below it, you can use the Perceptron update rule (more generally, gradient descent) to updated these weights. The problem is what to do with the other set of weights we do not get feedback in the intermediate layer(s). activation w 2 ij Output Hidden w 1 ij Input 7

Learning with a Multi-Layer Perceptron The problem is what to do with the other set of weights we do not get feedback in the intermediate layer(s). Solution: If all the activation functions are differentiable, then the output of the network is also activation a differentiable function of the input and weights in the network. Define an error function (multiple options) that is a differentiable function of the output, that this error function is also a differentiable function of the weights. We can then evaluate the derivatives of the error with respect to the weights, and use these derivatives to find weight values that minimize this error function. This can be done, for example, using gradient descent. This results in an algorithm called back-propagation. w 2 ij Output Hidden w 1 ij Input 8

Neural Networks Robust approach to approximating real-valued, discretevalued and vector valued target functions. Among the most effective general purpose supervised learning method currently known. Effective especially for complex and hard to interpret input data such as real-world sensory data, where a lot of supervision is available. The Backpropagation algorithm for neural networks has been shown successful in many practical problems handwritten character recognition, speech recognition, object recognition, some NLP problems 9

Neural Networks Neural Networks are functions: NN: XX YY where XX = 0,1 nn, or {0,1} nn and YY = 0,1, {0,1} NN can be used as an approximation of a target classifier In their general form, even with a single hidden layer, NN can approximate any function Algorithms exist that can learn a NN representation from labeled training data (e.g., Backpropagation). 10

Multi-Layer Neural Networks Multi-layer network were designed to overcome the computational (expressivity) limitation of a single threshold element. The idea is to stack several layers of threshold elements, each layer using the output of the previous layer as input. activation Output Hidden Input 11

Motivation for Neural Networks Inspired by biological systems But don t take this (as well as any other words in the new on emergence of intelligent behavior) seriously; We are currently on rising part of a wave of interest in NN architectures, after a long downtime from the mid-90-ies. Better computer architecture (GPUs, parallelism) A lot more data than before; in many domains, supervision is available. Current surge of interest has seen very minimal algorithmic changes 12

Motivation for Neural Networks Minimal to no algorithmic changes One potentially interesting perspective: Before we looked at NN only as function approximators. Now, we look at the intermediate representations generated while learning as meaningful Ideas are being developed on the value of these intermediate representations for transfer learning etc. We will present in the next two lectures a few of the basic architectures and learning algorithms, and provide some examples for applications 13

Basic Unit in Multi-Layer Neural Network Linear Unit: oo jj = ww. xx multiple layers of linear functions produce linear functions. We want to represent nonlinear functions. Threshold units: oo jj = ssssss(ww. xx TT) are not differentiable, hence unsuitable for gradient descent activation Output Hidden Input 15

Model Neuron (Logistic) Neuron is modeled by a unit jj connected by weighted The parameters so far? links ww iiii to other units ii. xx 1 xx 2 xx 3 xx 4 xx 5 xx 6 The set of connective weights: ww iiii The threshold value: TT jj ww 17 ww 67 xx 7 oo jj Use a non-linear, differentiable output function such as the sigmoid or logistic function Net input to a unit is defined as: Output of a unit is defined as: oo jj = net jj = ww iiii. xx ii 1 1 + exp (net jj TT jj ) 16

History: Neural Computation McCollough and Pitts (1943) showed how linear threshold units can be used to compute logical functions Can build basic logic gates AND: ww iiii = TT jj /nn OR: ww iiii = TT jj NOT: use negative weight Can build arbitrary logic circuits, finite-state machines and computers given these basis gates. Can specify any Boolean function using two layer network (w/ negation) DNF and CNF are universal representations net jj = ww iiii. xx ii 1 oo jj = 1 + exp (net jj TT jj ) 17

History: Learning Rules Hebb (1949) suggested that if two units are both active (firing) then the weights between them should increase: ww iiii = ww iiii + RRoo ii oo jj RR and is a constant called the learning rate Supported by physiological evidence Rosenblatt (1959) suggested that when a target output value is provided for a single neuron with fixed input, it can incrementally change weights and learn to produce the output using the Perceptron learning rule. assumes binary output units; single linear threshold unit Led to the Perceptron Algorithm See: http://people.idsia.ch/~juergen/who-invented-backpropagation.html 18

Perceptron Learning Rule Given: the target output for the output unit is tt jj the input the neuron sees is xx ii the output it produces is oo jj Update weights according to ww iiii ww iiii + RR tt jj oo jj xx ii If output is correct, don t change the weights If output is wrong, change weights for all inputs which are 1 If output is low (0, needs to be 1) increment weights If output is high (1, needs to be 0) decrement weights xx 1 xx 2 xx 3 xx 4 xx 5 xx 6 ww 17 ww 67 xx 7 TT jj oo jj 19

Widrow-Hoff Rule This incremental update rule provides an approximation to the goal: Find the best linear approximation of the data EEEEEE ww jj = 1 2 dd DD tt dd oo dd 2 where: oo dd = ww iiii. xx ii = ww jj. xx output of linear unit on example d tt dd = Target output for example d ii 20

Gradient Descent We use gradient descent determine the weight vector that minimizes EEEEEE ww jj ; Fixing the set DD of examples, EE is a function of ww jj At each step, the weight vector is modified in the direction that produces the steepest descent along the error surface. EEEEEE(ww) ww 3 ww 2 ww 1 ww 0 ww 21

Summary: Single Layer Network Variety of update rules Multiplicative Additive Batch and incremental algorithms Various convergence and efficiency conditions There are other ways to learn linear functions Linear Programming (general purpose) Probabilistic Classifiers ( some assumption) Key algorithms are driven by gradient descent 22

General Stochastic Gradient Algorithms Learning rate gradient w t+1 = w t r t g w Q(x t, y t, w t ) = w t r t g t LMS: Q((x, y), w) =1/2 (y w T x) 2 leads to the update rule (Also called Widrow s Adaline): w t+1 = w t + r (y t ww tt TT x t ) x t Here, even though we make binary predictions based on sgn (w T x) we do not take the sign of the dot-product into account in the loss. Another common loss function is: Hinge loss: Q((x, y), w) = max(0, 1 - y w T x) This leads to the perceptron update rule: The loss Q: a function of x, w and y w T x If y i ww TT ii x i > 1 (No mistake, by a margin): No update Otherwise (Mistake, relative to margin): w t+1 = w t + r y t x t Here g = -yx Good to think about the case of Boolean examples 23

Summary: Single Layer Network Variety of update rules Multiplicative Additive Batch and incremental algorithms Various convergence and efficiency conditions There are other ways to learn linear functions Linear Programming (general purpose) Probabilistic Classifiers ( some assumption) Key algorithms are driven by gradient descent However, the representational restriction is limiting in many applications 24

Learning with a Multi-Layer Perceptron It s easy to learn the top layer it s just a linear unit. Given feedback (truth) at the top layer, and the activation at the layer below it, you can use the Perceptron update rule (more generally, gradient descent) to updated these weights. The problem is what to do with the other set of weights we do not get feedback in the intermediate layer(s). activation w 2 ij Output Hidden w 1 ij Input 25

Learning with a Multi-Layer Perceptron The problem is what to do with the other set of weights we do not get feedback in the intermediate layer(s). Solution: If all the activation functions are differentiable, then the output of the network is also activation a differentiable function of the input and weights in the network. Define an error function (e.g., sum of squares) that is a differentiable function of the output, i.e. this error function is also a differentiable function of the weights. We can then evaluate the derivatives of the error with respect to the weights, and use these derivatives to find weight values that minimize this error function, using gradient descent (or other optimization methods). This results in an algorithm called back-propagation. w 2 ij Output Hidden w 1 ij Input 26

Some facts from real analysis Simple chain rule If zz is a function of yy, and yy is a function of xx Then zz is a function of xx, as well. Question: how to find We will use these facts to derive the details of the Backpropagation algorithm. z will be the error (loss) function. - We need to know how to differentiate z Intermediate nodes use a logistics function (or another differentiable step function). - We need to know how to differentiate it. 27

Some facts from real analysis Multiple path chain rule Slide Credit: Richard Socher 28

Some facts from real analysis Multiple path chain rule: general Slide Credit: Richard Socher 29

Backpropagation Learning Rule Since there could be multiple output units, we define the error as the sum over all the network output units. EEEEEE ww = 1 2 dd DD kk KK tt kkdd oo kkdd 2 where DD is the set of training examples, KK is the set of output units oo 1 oo kk (1, 0, 1, 0, 0) This is used to derive the (global) learning rule which performs gradient descent in the weight space in an attempt to minimize the error function. ww iijj = RR Function 1 ww iiii 30

Reminder: Model Neuron (Logistic) Neuron is modeled by a unit jj connected by weighted links ww iiii to other units ii. xx 1 xx 2 xx 3 xx 4 xx 5 xx 6 ww 17 ww 67 xx 7 oo jj Use a non-linear, differentiable output function such as the sigmoid or logistic function Net input to a unit is defined as: Output of a unit is defined as: oo jj = net jj = ww iiii. xx ii 1 Function 2 Function 3 1 + exp (net jj TT jj ) 31

Derivatives Function 1 (error): yy = 1 2 kk KK tt kk xx kk 2 yy = tt xx ii xxxx ii Function 2 (linear gate): yy = ww ii. xx ii yy = xx ww ii ii Function 3 (differentiable step function): yy = yy xx = 1 1+exp{ (xx TT)} exp{ (xx TT)} (1+exp{ (xx TT)}) 2 = yy(1 yy) oo 1 oo kk ii jj ww iiii 32

Derivation of Learning Rule The weights are updated incrementally; the error is computed for each example and the weight update is then derived. EEEErr dd ww = 1 2 kk KK tt kk oo kk 2 ww iiii influences the output only through net jj net jj = ww iiii. xx iiii Therefore: EE dd ww iiii = EE dd net jj net jj ww iiii oo 1 oo kk ii jj ww iiii 33

Derivation of Learning Rule (2) Weight updates of output units: ww iiii influences the output only through net jj Therefore: EE dd ww iiii = EE dd net jj = EE dd o jj net jj ww iiii oo jj net jj net jj ww iiii jj ii ww iiii = tt jj oo jj oo jj 1 oo jj xx iiii EEEErr dd ww = 1 2 kk KK tt kk oo kk 2 oo jj = oo jj = oo net jj (1 oo net jj ) jj jj = ww iiii. xx iiii 1 1 + exp{ (net jj TT jj )} 34

Derivation of Learning Rule (3) Weights of output units: ww iiii is changed by: ww iiii = RR tt jj oo jj oo jj 1 oo jj xx iiii = RRδδ jj xx iiii oo jj jj ww iiii where δδ jj = tt jj oo jj oo jj 1 oo jj xx iiii ii 35

Derivation of Learning Rule (4) Weights of hidden units: ww iiii Influences the output only through all the units whose direct input include jj EE dd ww iiii = EE dd net jj net jj ww iiii = net jj = ww iiii. xx iiii jj oo kk kk ww iiii = kk dddddddddddddddddddd(jj) EE dd net kk net kk net jj xx iiii ii = kk dddddddddddddddddddd(jj) δδ kk net kk net jj xx iiii 36

Derivation of Learning Rule (5) Weights of hidden units: ww iiii influences the output only through all the units whose direct input include jj oo kk kk EE dd ww iiii = kk dddddddddddddddddddd(jj) = δδ kk kk dddddddddddddddddddd(jj) δδ kk net kk net jj xx iiii = net kk oo jj oo jj net jj xx iiii jj ii ww iiii = kk dddddddddddddddddddd(jj) δδ kk ww jjjj oo jj (1 oo jj ) xx iiii 37

Derivation of Learning Rule (6) Weights of hidden units: ww iiii is changed by: = RRδδ jj xx iiii Where δδ jj = oo jj 1 oo jj. ww iiii = RR oo jj 1 oo jj. kk dddddddddddddddddddd jj δδ kk ww jjjj First determine the error for the output units. Then, backpropagate this error layer by layer through the network, changing weights appropriately in each layer. kk dddddddddddddddddddd jj δδ kk ww jjjj xx iiii jj oo kk kk ii ww iiii 38

The Backpropagation Algorithm Create a fully connected three layer network. Initialize weights. Until all examples produce the correct output within εε (or other criteria) For each example in the training set do: 1. Compute the network output for this example 2. Compute the error between the output and target value δδ kk = tt kk oo kk oo kk 1 oo kk 1. For each output unit k, compute error term δδ jj = oo jj 1 oo jj. kk dddddddddddddddddddd jj 1. For each hidden unit, compute error term: ww iiii = RRδδ jj xx iiii 1. Update network weights End epoch δδ kk ww jjjj 39

More Hidden Layers The same algorithm holds for more hidden layers. input h 1 h 2 h 3 output 40

Comments on Training No guarantee of convergence; may oscillate or reach a local minima. In practice, many large networks can be trained on large amounts of data for realistic problems. Many epochs (tens of thousands) may be needed for adequate training. Large data sets may require many hours of CPU Termination criteria: Number of epochs; Threshold on training set error; No decrease in error; Increased error on a validation set. To avoid local minima: several trials with different random initial weights with majority or voting techniques 41

Over-training Prevention Running too many epochs may over-train the network and result in over-fitting. (improved result on training, decrease in performance on test set) Keep an hold-out validation set and test accuracy after every epoch Maintain weights for best performing network on the validation set and return it when performance decreases significantly beyond that. To avoid losing training data to validation: Use 10-fold cross-validation to determine the average number of epochs that optimizes validation performance Train on the full data set using this many epochs to produce the final results 42

Over-fitting prevention Too few hidden units prevent the system from adequately fitting the data and learning the concept. Using too many hidden units leads to over-fitting. Similar cross-validation method can be used to determine an appropriate number of hidden units. (general) Another approach to prevent over-fitting is weight-decay: all weights are multiplied by some fraction in (0,1) after every epoch. Encourages smaller weights and less complex hypothesis Equivalently: change Error function to include a term for the sum of the squares of the weights in the network. (general) 43

Proposed by (Hinton et al, 2012) Dropout training Each time decide whether to delete one hidden unit with some probability p 44

Dropout training Dropout of 50% of the hidden units and 20% of the input units (Hinton et al, 2012) 45

Dropout training Model averaging effect Among 2 H models, with shared parameters H: number of units in the network Only a few get trained Much stronger than the known regularizer What about the input space? Do the same thing! 46

Input-Output Coding Appropriate coding of inputs and outputs can make learning problem easier and improve generalization. Encode each binary feature as a separate input unit; One way to do it, if you start with a collection of sparsely representation examples, is to use dimensionality reduction For multi-valued methods: features include one binary unit per - Your m examples are represented as a m x 10 value rather than trying to encode input 6 matrix information in - Multiple it by a random matrix of size 10 fewer units. 6 x 300, say. - Random matrix: Normal(0,1) - New representation: m x 300 dense rows Very common today to use distributed representation of the input real valued, dense representation. For disjoint categorization problem, best to have one output unit for each category rather than encoding N categories into log N bits. 47

Representational Power The Backpropagation version presented is for networks with a single hidden layer, But: Any Boolean function can be represented by a two layer network (simulate a two layer AND-OR network) Any bounded continuous function can be approximated with arbitrary small error by a two layer network. Sigmoid functions provide a set of basis function from which arbitrary function can be composed. Any function can be approximated to arbitrary accuracy by a three layer network. 48

Hidden Layer Representation Weight tuning procedure sets weights that define whatever hidden units representation is most effective at minimizing the error. Sometimes Backpropagation will define new hidden layer features that are not explicit in the input representation, but which capture properties of the input instances that are most relevant to learning the target function. Trained hidden units can be seen as newly constructed features that re-represent the examples so that they are linearly separable 49

Auto-associative Network An auto-associative network trained with 8 inputs, 3 hidden units and 8 output nodes, where the output must reproduce the input. When trained with vectors with only one bit on INPUT HIDDEN 1 0 0 0 0 0 0 0.89.40 0.8 0 1 0 0 0 0 0 0.97.99.71. 0 0 0 0 0 0 0 1.01.11.88 1 0 0 0 1 0 0 0 Learned the standard 3-bit encoding for the 8 bit vectors. Illustrates also data compression aspects of learning 1 0 0 0 1 0 0 0 51

Sparse Auto-encoder Encoding: Decoding: Goal: perfect reconstruction of input vector xx, by the output xx = h θθ (xx) Where θθ = {WW, WW } Minimize an error function ll(h θθ xx, xx) For example: ll h θθ xx, xx = h θθ xx xx 2 And regularize it yy = ff(wwxx + bb) xx = gg(ww yy + bb ) min θθ ll h θθ xx, xx + ww ii xx ii After optimization drop the reconstruction layer and add a new layer 52

Stacking Auto-encoder Add a new layer, and a reconstruction layer for it. And try to tune its parameters such that And continue this for each layer 53

Beyond supervised learning So far what we had was purely supervised. Initialize parameters randomly Train in supervised mode typically, using backprop Used in most practical systems (e.g. speech and image recognition) Unsupervised, layer-wise + supervised classifier on top Train each layer unsupervised, one after the other Train a supervised classifier on top, keeping the other layers fixed Good when very few labeled samples are available Unsupervised, layer-wise + global supervised fine-tuning Train each layer unsupervised, one after the other Add a classifier layer, and retrain the whole thing supervised Good when label set is poor (e.g. pedestrian detection) We won t talk about unsupervised pretraining here. But it s good to have this in mind, since it is an active topic of research. 54

NN-2 55

Recap: Multi-Layer Perceptrons Multi-layer network A global approximator Different rules for training it The Back-propagation Forward step Back propagation of errors activation Congrats! Now you know the hardest concept about neural networks! Today: Convolutional Neural Networks Recurrent Neural Networks Output Hidden Input 56

Receptive Fields The receptive field of an individual sensory neuron is the particular region of the sensory space (e.g., the body surface, or the retina) in which a stimulus will trigger the firing of that neuron. In the auditory system, receptive fields can correspond to volumes in auditory space Designing proper receptive fields for the input Neurons is a significant challenge. Consider a task with image inputs Receptive fields should give expressive features from the raw input to the system How would you design the receptive fields for this problem? 57

A fully connected layer: Example: 100x100 images 1000 units in the input Problems: 10^7 edges! Spatial correlations lost! Variables sized inputs. Slide Credit: Marc'Aurelio Ranzato 58

Consider a task with image inputs: A locally connected layer: Example: 100x100 images 1000 units in the input Filter size: 10x10 Local correlations preserved! Problems: 10^5 edges This parameterization is good when input image is registered (e.g., face recognition). Variable sized inputs, again. Slide Credit: Marc'Aurelio Ranzato 59

Convolutional Layer A solution: Filters to capture different patterns in the input space. Share parameters across different locations (assuming input is stationary) Convolutions with learned filters Filters will be learned during training. The issue of variable-sized inputs will be resolved with a pooling layer. So what is a convolution? Slide Credit: Marc'Aurelio Ranzato 60

Convolution Operator Convolution operator: takes two functions and gives another function One dimension: xx h tt = xx ττ h tt ττ dddd Convolution is very similar to crosscorrelation, except that in convolution one of the functions is flipped. xx h [nn] = mm xx mm h[nn mm] 61

Convolution Operator (2) Convolution in two dimension: The same idea: flip one matrix and slide it on the other matrix Example: Sharpen kernel: Try other kernels: http://setosa.io/ev/image-kernels/ 62

Convolution Operator (3) Convolution in two dimension: The same idea: flip one matrix and slide it on the other matrix Slide Credit: Marc'Aurelio Ranza 63

Complexity of Convolution Complexity of convolution operator is nnnnn nn, for nn inputs. Uses Fast-Fourier-Transform (FFT) For two-dimension, each convolution takes MMMMlog MMMM time, where the size of input is MMMM. Slide Credit: Marc'Aurelio Ranzato 64

Convolutional Layer The convolution of the input (vector/matrix) with weights (vector/matrix) results in a response vector/matrix. We can have multiple filters in each convolutional layer, each producing an output. If it is an intermediate layer, it can have multiple inputs! Convolutional Layer One can add nonlinearity at the output of convolutional layer Filter Filter Filter Filter 65

Pooling Layer How to handle variable sized inputs? A layer which reduces inputs of different size, to a fixed size. Pooling Slide Credit: Marc'Aurelio Ranzato 66

Pooling Layer How to handle variable sized inputs? A layer which reduces inputs of different size, to a fixed size. Pooling Different variations Max pooling h ii nn = max h [ii] ii NN(nn) Average pooling h ii nn = 1 nn L2-pooling ii NN(nn) h [ii] etc h ii nn = 1 nn ii NN(nn) h 2 [ii] 67

Convolutional Nets One stage structure: Whole system: Convol. Pooling Input Image Stage 1 Stage 2 Stage 3 Fully Connected Layer Class Label Slide Credit: Druv Bhatra 68

Training a ConvNet The same procedure from Back-propagation applies here. Remember in backprop we started from the error terms in the last stage, and passed them back to the previous layers, one by one. Back-prop for the pooling layer: Consider, for example, the case of max pooling. This layer only routes the gradient to the input that has the highest value in the forward pass. Hence, during the forward pass of a pooling layer it is common to keep track of the index of the max activation (sometimes also called the switches) so that gradient routing is efficient during backpropagation. Therefore we have: δδ = EE dd yy ii xx ii Convol. yy ii Pooling δδ first layer = δδ last layer = EE dd yy first layer EE dd yy last layer EE dd Input Image Stage 1 Stage 2 Stage 3 Fully Connected Layer Class Label 69

We derive the update rules for a 1D convolution, but the idea is the same for bigger dimensions. Training a ConvNet Back-prop for the convolutional layer: mm 1 yy = ww xx yy ii = aa=0 yy = ff yy yy ii = ff( yy ii ) ii mm 1 ww aa xx ii aa = aa=0 ww ii aa xx aa ii The convolution A differentiable nonlinearity Now we can repeat this for each stage of ConvNet. xx ii EE dd ww aa = EE dd yy ii = δδ = EE dd xx aa = Convol. mm 1 EEdd ii=0 yy ii yy ii yy ii ww aa = ii=0 EE dd yy ii yy ii yy ii = EE dd yy ii ff ( yy) mm 1 EEdd ii=0 yy ii yy ii xx aa Pooling mm 1 EEdd yy ii xx ii aa mm 1 EEdd = ii=0 yy ii ww ii aa δδ first layer = Now we have everything in this layer to update the filter We need to pass the gradient to the previous layer EE dd yy first layer δδ last layer = EE dd yy last layer EE dd Input Image Stage 1 Stage 2 Stage 3 Fully Connected Layer Class Label 70

Convolutional Nets Input Image Stage 1 Stage 2 Stage 3 Fully Connected Layer Class Label Feature visualization of convolutional net trained on ImageNet from [Zeiler & Fergus 2013] 71

ConvNet roots Fukushima, 1980s designed network with same basic structure but did not train by backpropagation. The first successful applications of Convolutional Networks by Yann LeCun in 1990's (LeNet) Was used to read zip codes, digits, etc. Many variants nowadays, but the core idea is the same Example: a system developed in Google (GoogLeNet) Compute different filters Compose one big vector from all of them Layer this iteratively See more: http://arxiv.org/pdf/1409.4842v1.pdf 72

Depth matters Slide from [Kaiming He 2015] 73

Practical Tips Before large scale experiments, test on a small subset of the data and check the error should go to zero. Overfitting on small training Visualize features (feature maps need to be uncorrelated) and have high variance Bad training: many hidden units ignore the input and/or exhibit strong correlations. Figure Credit: Marc'Aurelio Ranzato 74

Debugging Training diverges: Learning rate may be too large decrease learning rate BackProp is buggy numerical gradient checking Loss is minimized but accuracy is low Check loss function: Is it appropriate for the task you want to solve? Does it have degenerate solutions? NN is underperforming / under-fitting Compute number of parameters if too small, make network larger NN is too slow Compute number of parameters Use distributed framework, use GPU, make network smaller Many of these points apply to many machine learning models, no just neural networks. 75

CNN for vector inputs Let s study another variant of CNN for language Example: sentence classification (say spam or not spam) First step: represent each word with a vector in R dd This is not a spam O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O Concatenate the vectors O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O Now we can assume that the input to the system is a vector R dddd Where the input sentence has length ll (ll = 5 in our example ) Each word vector s length dd (dd = 7 in our example ) 76

Convolutional Layer on vectors Think about a single convolutional layer A bunch of vector filters Each defined in R ddh Where h is the number of the words the filter covers Size of the word vector dd Find its (modified) convolution with the input vector O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O Result of the convolution with the filter cc = [cc 1,., cc nn h+1 ] O O O O O O O Convolution with a filter that spans 2 words, is operating on all of the bigrams (vectors of two consecutive word, concatenated): this is, is not, not a, a spam. Regardless of whether it is grammatical (not appealing linguistically) O O O O O O O cc 1 = ff(ww. xx 1:h cc 2 ) = ff(ww. xx h+1:2h cc 3 = ) ff(ww. xx 2h+1:3h cc 4 = ff(ww. ) xx 3h+1:4h ) O O O O 77

Convolutional Layer on vectors Get word vectors for each words This is not a spam O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O Concatenate vectors Perform convolution with each filter O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O * O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O Filter bank How are we going to handle the variable sized response vectors? Pooling! #of filters O O O O O O O O O O O O O O O #words - #length of filter + 1 Set of response vectors 78

Convolutional Layer on vectors Get word vectors for each words This is not a spam O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O Concatenate vectors Perform convolution with each filter O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O * O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O Filter bank Pooling on filter responses #of filters O O O O O O O O O O O O O O O O O O O O O O O O O O O O O #words - #length of filter + 1 Some choices for pooling: k-max, mean, etc Now we can pass the fixed-sized vector to a logistic unit (softmax), or give it to multi-layer network (last session) 79

Recurrent Neural Networks Multi-layer feed-forward NN: DAG Just computes a fixed sequence of non-linear learned transformations to convert an input patter into an output pattern Recurrent Neural Network: Digraph Has cycles. Cycle can act as a memory; The hidden state of a recurrent net can carry along information about a potentially unbounded number of previous inputs. They can model sequential data in a much more natural way. 80

Equivalence between RNN and Feed-forward NN Assume that there is a time delay of 1 in using each connection. The recurrent net is just a layered net that keeps reusing the same weights. w1 w4 time=3 time=2 W1 W2 W3 W4 W1 W2 W3 W4 w2 w3 time=1 W1 W2 W3 W4 time=0 Slide Credit: Geoff Hinton 81

Recurrent Neural Networks Training a general RNN s can be hard Here we will focus on a special family of RNN s Prediction on chain-like input: Example: POS tagging words of a sentence Issues : XX = This is a sample sentence Y = DT VBZ DT NN NN Structure in the output: There is connections between labels Interdependence between elements of the inputs: The final decision is based on an intricate interdependence of the words on each other. Variable size inputs: e.g. sentences differ in size How would you go about solving this task? 82

Recurrent Neural Networks A chain RNN: Has a chain-like structure Each input is replaced with its vector representation xx tt Hidden (memory) unit h tt contain information about previous inputs and previous hidden units h tt 1, h tt 2, etc Computed from the past memory and current word. It summarizes the sentence up to that time. xx tt 1 xx tt xx tt+1 O O O O O O O O O O O O O O O Input layer O O O O O O O O O O h tt 1 h tt h tt+1 Memory layer O O O O O 83

Recurrent Neural Networks A popular way of formalizing it: h tt = ff(ww h h tt 1 + WW ii xx tt ) Where ff is a nonlinear, differentiable (why?) function. Outputs? Many options; depending on problem and computational resource xx tt 1 xx tt xx tt+1 O O O O O O O O O O O O O O O Input layer O O O O O O O O O O h tt 1 h tt h tt+1 Memory layer O O O O O 84

Recurrent Neural Networks Prediction for xx tt, with h tt Prediction for xx tt, with h tt,, h tt ττ Prediction for the whole chain yy tt = softmax WW oo h tt yy tt = softmax αα ii WW oo yy TT = softmax WW oo h TT ττ ii=0 ii htt ii xx tt 1 xx tt xx tt+1 O O O O O O O O O O O O O O O Input layer O O O O O O O O O O h tt 1 h tt h tt+1 Memory layer O O O O O Some inherent issues with RNNs: Recurrent neural nets cannot capture phrases without prefix context They often capture too much of last words in final vector 85

Bi-directional RNN One of the issues with RNN: Hidden variables capture only one side context A bi-directional structure xx tt 1 xx tt xx tt+1 O O O O O O O O O O O O O O O h tt = ff(ww h h tt 1 + WW ii xx tt ) h tt 1 h tt h tt+1 h tt = ff( WW h h tt+1 + WW ii xx tt ) O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O yy tt = softmax WW oo h tt + WW oo h tt h tt 1 h tt h tt+1 yy tt 1 yy tt yy tt+1 86

Stack of bi-directional networks Use the same idea and make your model further complicated: 87

Training RNNs How to train such model? Generalize the same ideas from back-propagation Total output error: EE yy, tt = TT tt=1 Parameters? WW oo, WW ii, WW h + vectors for input TT = EE tt tt=1 EE TT tt = tt=1 EE tt yy tt yy tt h tt EE tt yy tt, tt tt h tt h tt kk h tt kk xx tt 1 xx tt xx tt+1 O O O O O O O O O O O O O O O Reminder: yy tt = softmax WW oo h tt h tt = ff(ww h h tt 1 + WW ii xx tt ) This sometimes is called Backpropagation Through Time, since the gradients are propagated back through time. O O O O O O O O O O h tt 1 h tt h tt+1 O O O O O yy tt 1 yy tt yy tt+1 88

Recurrent Neural Network TT = tt=1 EE tt yy tt yy tt h tt h tt h tt kk h tt kk Reminder: yy tt = softmax WW oo h tt h tt = ff(ww h h tt 1 + WW ii xx tt ) h tt h tt 1 = WW h diag ff (WW h h tt 1 + WW ii xx tt ) h tt h tt kk = tt jj=tt kk+1 h jj h jj 1 = tt jj=tt kk+1 diag aa 1,, aa nn = WW h diag ff (WW h h tt 1 + WW ii xx tt ) aa 1 0 0 0 0 0 0 aa nn xx tt 1 xx tt xx tt+1 O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O h tt 1 h tt h tt+1 yy tt 1 yy tt yy tt+1 89

Vanishing/exploding gradients Vanishing gradients are quite prevalent and a serious issue. A real example h tt h kk Training a feed-forward network y-axis: sum of the gradient norms Earlier layers have exponentially smaller sum of gradient norms This will make training earlier layers much slower. h tt = h tt kk tt jj=tt kk+1 tt jj=tt kk+1 WW h diag ff (WW h h tt 1 + WW ii xx tt ) WW h diag ff (WW h h tt 1 + WW ii xx tt ) tt jj=tt kk+1 αααα = αααα kk Gradient can become very small or very large quickly, and the locality assumption of gradient descent breaks down (Vanishing gradient) [Bengio et al 1994] 90

Vanishing/exploding gradients In an RNN trained on long sequences (e.g. 100 time steps) the gradients can easily explode or vanish. So RNNs have difficulty dealing with long-range dependencies. Many methods proposed for reduce the effect of vanishing gradients; although it is still a problem Introduce shorter path between long connections Abandon stochastic gradient descent in favor of a much more sophisticated Hessian-Free (HF) optimization Add fancier modules that are robust to handling long memory; e.g. Long Short Term Memory (LSTM) One trick to handle the exploding-gradients: Clip gradients with bigger sizes: Defnne gg = If gg tthrrrrrrhoooooo then gg tthrrrrrrhoooooo gg gg 91