Presentation is loading. Please wait.

Presentation is loading. Please wait.

Zhu Han University of Houston

Similar presentations


Presentation on theme: "Zhu Han University of Houston"— Presentation transcript:

1 Signal processing and Networking for Big Data Applications Lectures 14-15: CNN and RNN Details
Zhu Han University of Houston Thanks Xusheng Du and Kevin Tsai For Slide Preparation

2 CNN outline The convolution operation Motivation Pooling
Convolution and Pooling as an Infinitely Strong Prior

3 The convolution operation
Convolutional networks convolutional (LeCun, 1989), also known as neural networks or CNNs, are a specialized kind of neural network for processing data that has a known, grid-like topology. Convolutional networks are simply neural networks that use convolution in place of general matrix multiplication in at least one of their layers.

4 The convolution operation
This operation is called convolution. The convolution operation is typically denoted with an asterisk:

5 The convolution operation
In our example, w needs to be a valid probability density function, or the output is not a weighted average. Also, w needs to be 0 for all negative arguments, or it will look into the future, which is presumably beyond our capabilities. In convolutional network terminology, the first argument (in this example, the function x) to the convolution is often referred to as the input and the second argument (in this example, the function w) as the kernel. The output is sometimes referred to as the feature map.

6 The convolution operation
In machine learning applications, the input is usually a multidimensional array of data and the kernel is usually a multidimensional array of parameters that are adapted by the learning algorithm. We will refer to these multidimensional arrays as tensors.

7 The convolution operation
Convolution is commutative, meaning we can equivalently write: Usually the latter formula is more straightforward to implement in a machine learning library, because there is less variation in the range of valid values of m and n.

8 The convolution operation

9 CNN outline The convolution operation Motivation Pooling
Convolution and Pooling as an Infinitely Strong Prior

10 motivation Convolution leverages three important ideas that can help improve a machine learning system: sparse interactions, parameter sharing and equivariant representations.

11 motivation This means every output unit interacts with every input unit. Convolutional networks, however, typically have sparse interactions (also referred to as sparse connectivity or sparse weights). This is accomplished by making the kernel smaller than the input. This means that we need to store fewer parameters, which both reduces the memory requirements of the model and improves its statistical efficiency.

12 motivation Sparse Connectivity

13 motivation The receptive field of the units in the deeper layers of a convolutional network is larger than the receptive field of the units in the shallow layers

14 motivation Parameter sharing refers to using the same parameter for more than one function in a model. In a traditional neural net, each element of the weight matrix is used exactly once when computing the output of a layer. It is multiplied by one element of the input and then never revisited. As a synonym for parameter sharing, one can say that a network has tied weights, because the value of the weight applied to one input is tied to the value of a weight applied elsewhere.

15 motivation This does not affect the runtime of forward propagation—it is still O(k × n)—but it does further reduce the storage requirements of the model to k parameters. Recall that k is usually several orders of magnitude less than m. Since m and n are usually roughly the same size, k is practically insignificant compared to m× n.

16 motivation

17 motivation 320*280 319*280 Highlight vertical lines

18 motivation In the case of convolution, the particular form of parameter sharing causes the layer to have a property called equivariance to translation. Specifically, a function f(x) is equivariant to a function g if If we move an event later in time in the input, the exact same representation of it will appear in the output, just later in time. If we move the object in the input, its representation will move the same amount in the output.

19 CNN outline The convolution operation Motivation Pooling
Convolution and Pooling as an Infinitely Strong Prior

20 pooling A typical layer of a convolutional network consists of three stages: In the first stage, the layer performs several convolutions in parallel to produce a set of linear activations. In the second stage, each linear activation is run through a nonlinear activation function, such as the rectified linear activation function. This stage is sometimes called the detector stage. In the third stage, we use a pooling function to modify the output of the layer further.

21 pooling

22 pooling A pooling function replaces the output of the net at a certain location with a summary statistic of the nearby outputs. For example, the max pooling (Zhou and Chellappa, 1988) operation reports the maximum output within a rectangular neighborhood.

23 pooling In all cases, pooling helps to make the representation become approximately invariant to small translations of the input. Invariance to local translation can be a very useful property if we care more about whether some feature is present than exactly where it is.

24 pooling Max pooling introduces invariance

25 pooling When determining whether an image contains a face, we need not know the location of the eyes with pixel-perfect accuracy, we just need to know that there is an eye on the left side of the face and an eye on the right side of the face.

26 pooling Pooling over spatial regions produces invariance to translation, but if we pool over the outputs of separately parametrized convolutions, the features can learn which transformations to become invariant to.

27 pooling

28 pooling Because pooling summarizes the responses over a whole neighborhood, it is possible to use fewer pooling units than detector units, by reporting summary statistics for pooling regions spaced k pixels apart rather than 1 pixel apart.

29 pooling Pooling with downsampling

30 pooling When the number of parameters in the next layer is a function of its input size (such as when the next layer is fully connected and based on matrix multiplication) this reduction in the input size can also result in improved statistical efficiency and reduced memory requirements for storing the parameters.

31 pooling For many tasks, pooling is essential for handling inputs of varying size. For example, if we want to classify images of variable size, the input to the classification layer must have a fixed size. This is usually accomplished by varying the size of an offset between pooling regions so that the classification layer always receives the same number of summary statistics regardless of the input size.

32 pooling There are many examples of complete convolutional network architectures for classification using convolution and pooling.

33 pooling Different ways of pooling

34 CNN outline The convolution operation Motivation Pooling
Convolution and Pooling as an Infinitely Strong Prior

35 Convolution and pooling as an infinitely strong prior
Priors can be considered weak or strong depending on how concentrated the probability density in the prior is. A weak prior is a prior distribution with high entropy, such as a Gaussian distribution with high variance. Such a prior allows the data to move the parameters more or less freely. A strong prior has very low entropy, such as a Gaussian distribution with low variance. Such a prior plays a more active role in determining where the parameters end up.

36 Convolution and pooling as an infinitely strong prior
An infinitely strong prior places zero probability on some parameters and says that these parameter values are completely forbidden, regardless of how much support the data gives to those values. In convolution networks, the infinitely strong prior says that the weights for one hidden unit must be identical to the weights of its neighbor, but shifted in space. The prior also says that the weights must be zero, except for in the small, spatially contiguous receptive field assigned to that hidden unit.

37 Convolution and pooling as an infinitely strong prior
One key insight is that convolution and pooling can cause underfitting. If a task relies on preserving precise spatial information, then using pooling on all features can increase the training error. When a task involves incorporating information from very distant locations in the input, then the prior imposed by convolution may be inappropriate. Another key insight from this view is that we should only compare convolutional models to other convolutional models in benchmarks of statistical learning performance.

38 Break

39 RNN outline Unfolding Computational Graph Recurrent Neural Networks
Leaky Units and Other Strategies for Multiple Time Scales Long Short-Term Memory and Other Gated RNNs

40 Unfolding computational graph
Much as a convolutional network is a neural network that is specialized for processing a grid of values X such as an image, a recurrent neural network is a neural network that is specialized for processing a sequence of values x(1), , x(τ) .

41 Unfolding computational graph
Parameter sharing makes it possible to extend and apply the model to examples of different forms (different lengths, here) and generalize across them. For example, consider the two sentences “I went to Nepal in 2009” and “In 2009, I went to Nepal.” If we ask a machine learning model to read each sentence and extract the year in which the narrator went to Nepal, we would like it to recognize the year 2009 as the relevant piece of information, whether it appears in the sixth or the second of a sentance

42 Unfolding computational graph
We refer to RNNs as operating on a sequence that contains vectors x(t) with the time step index t ranging from 1 to τ . The time step index need not literally refer to the passage of time in the real world, but only to the position in the sequence.

43 Unfolding computational graph
Extends the idea of a computational graph to include cycles. These cycles represent the influence of the present value of a variable on its own value at a future time step.

44 Unfolding computational graph
Unfolding a recursive or recurrent computation into a computational graph that has a repetitive structure. For example, consider the classical form of a dynamical system: s(t) is called the state of the system. This equation is recurrent because the definition of s at time t refers back to the same definition at time t − 1.

45 Unfolding computational graph
The classical dynamical system can be illustrated as an unfolded computational graph. Each node represents the state at some time t and the function f maps the state at t to the state at t + 1. The same parameters (the same value of θ used to parametrize f) are used for all time steps.

46 Unfolding computational graph
Let us consider a dynamical system driven by an external signal x(t)

47 Unfolding computational graph
Typical RNNs will add extra architectural features such as output layers that read information out of the state h to make predictions.

48 Unfolding computational graph
Use h(t) as a kind of lossy summary of the task-relevant aspects of the past sequence of inputs up to t. This summary is in general necessarily lossy, since it maps an arbitrary length sequence (x(t), x(t−1), x(t−2), , x(2), x(1)) to a fixed length vector h(t).

49 Unfolding computational graph
For example, if the RNN is used in statistical language modeling, typically to predict the next word given previous words, it may not be necessary to store all of the information in the input sequence up to time t, but rather only enough information to predict the rest of the sentence.

50 Unfolding computational graph
A recurrent network with no outputs

51 Unfolding computational graph
The function g(t) takes the whole past sequence (x(t), x(t−1), x(t−2), , x(2), x(1)) as input and produces the current state, but the unfolded recurrent structure allows us to factorize g(t) into repeated application of a function f .

52 Unfolding computational graph
The unfolding process introduces two major advantages: Regardless of the sequence length, the learned model always has the same input size, because it is specified in terms of transition from one state to another state, rather than specified in terms of a variable-length history of states. It is possible to use the same transition function f with the same parameters at every time step

53 RNN outline Unfolding Computational Graph Recurrent Neural Networks
Leaky Units and Other Strategies for Multiple Time Scales Long Short-Term Memory and Other Gated RNNs

54 Recurrent neural networks
Some examples of important design patterns for RNN: Recurrent networks that produce an output at each time step and have recurrent connections between hidden units (1) Recurrent networks that produce an output at each time step and have recurrent connections only from the output at one time step to the hidden units at the next time step (2) Recurrent networks with recurrent connections between hidden units, that read an entire sequence and then produce a single output (3)

55 Recurrent neural networks
(1)

56 Recurrent neural networks
Training is very expensive !

57 Recurrent neural networks
(2) Less powerful but easy to train

58 Recurrent neural networks
(2) During training, the ideal value of the output of previous time step is already known

59 Recurrent neural networks
(2) Teacher forcing Use real labeled data at time t-1 to train time t

60 Recurrent neural networks
(3) Time-unfolded recurrent neural network with a single output at the end of the sequence. Such a network can be used to summarize a sequence and produced a fixed-size representation

61 Recurrent neural networks
Computing gradient in RNN: Backpropagation Through Time (BPTT)

62 Recurrent neural networks
Backpropagation Through Time (BPTT) (1)

63 Recurrent neural networks
Backpropagation Through Time (BPTT) (2)

64 Recurrent neural networks
Backpropagation Through Time (BPTT) (3)

65 Recurrent neural networks
Backpropagation Through Time (BPTT) (4) is the diagonal matrix containing the elements

66 Deep Recurrent networks
For parameters, the gradient denoted as:

67 Deep Recurrent networks
The computation in most RNNs can be decomposed into three blocks of parameters and associated transformations: 1. from the input to the hidden state 2. from the previous hidden state to the next hidden state 3. from the hidden state to the output

68 Deep Recurrent networks
a. The hidden recurrent state can be broken down into groups organized hierarchically. b. Every computation components can be made deep c. skip connections to mitigate the path-lengthening effect

69 Recursive networks A recursive network has a computational graph that generalizes that of the recurrent network from a chain to a tree.

70 challenge of long-term dependencies
The basic problem is that gradients propagated over many stages tend to either vanish (most of the time) or explode (rarely, but with much damage to the optimization).

71 challenge of long-term dependencies
We can think of the recurrence relation as a very simple recurrent neural network lacking a nonlinear activation function, and input x

72 challenge of long-term dependencies
This essentially involved a power method

73 challenge of long-term dependencies
If W admits an eigendecomposition, then W can be written like this way It can be further simplified with orthogonal Q

74 challenge of long-term dependencies
Basically, the problem arises because the same matrix multiplication operation is implemented. If we consider a non-recurrent case, is given at each time step, then the state at time t is given by Suppose those weights are generated randomly, and independent from one another, we can control the varience of the weights, so the explosion and vanishing problem won't happpen

75 RNN outline Unfolding Computational Graph Recurrent Neural Networks
Leaky Units and Other Strategies for Multiple Time Scales Long Short-Term Memory and Other Gated RNNs

76 Leaky units and other strategies
One way to deal with long-term dependencies is to design a model that operates at multiple time scales Some parts of the model operate at fine-grained time scales and can handle small details, while other parts operate at coarse time scales and transfer information from the distant past to the present more efficiently.

77 Leaky units and other strategies
Various strategies for building both fine and coarse time scales are possible. These include the addition of skip connections across time, “leaky units” that integrate signals with different time constants, and the removal of some of the connections used to model fine-grained time scales.

78 Leaky units and other strategies
Adding Skip Connections through Time: Gradients may vanish or explode exponentially with respect to the number of time steps. Lin et al. (1996) introduced recurrent connections with a time-delay of d to mitigate this problem. Gradients now diminish exponentially as a function of rather than τ .

79 Leaky units and other strategies
Leaky Units and a Spectrum of Different Time Scales: Hidden units with linear self-connections: When we accumulate a running average the 𝛼 parameter is an example of a linear self-connection from to .

80 Leaky units and other strategies
Leaky Units and a Spectrum of Different Time Scales: The linear self-connection approach allows this effect to be adapted more smoothly and flexibly by adjusting the real-valued 𝛼 rather than by adjusting the integer-valued skip length.

81 Leaky units and other strategies
Removing Connections: This idea differs from the skip connections through time discussed earlier because it involves actively removing length-one connections and replacing them with longer connections.

82 Leaky units and other strategies
Removing Connections: Skip connections through time add edges. Units receiving such new connections may learn to operate on a long time scale but may also choose to focus on their other short-term connections.

83 RNN outline Unfolding Computational Graph Recurrent Neural Networks
Leaky Units and Other Strategies for Multiple Time Scales Long Short-Term Memory and Other Gated RNNs

84 Long short-term memory
Long Short Term Memory networks – usually just called “LSTMs” – are a special kind of RNN, capable of learning long-term dependencies. They were introduced by Hochreiter & Schmidhuber (1997)

85 Long short-term memory
The LSTM has been found extremely successful in many applications, such as unconstrained handwriting recognition (Graves et al., 2009), speech recognition (Graves et al., 2013; Graves and Jaitly, 2014), handwriting generation (Graves, 2013), machine translation (Sutskever et al., 2014), image captioning (Kiros et al., 2014b; Vinyals et al., 2014b; Xu et al., 2015) and parsing (Vinyals et al., 2014a).

86 Long short-term memory

87 Long short-term memory
Recall simple chain structure of basic RNNs The repeating module in a standard RNN contains a single layer.

88 Long short-term memory
An example of LSTM: The repeating module in an LSTM contains four interacting layers.

89 Long short-term memory
Core idea behind LSTM The key to LSTMs is the cell state, the horizontal line running through the top of the diagram. It runs straight down the entire chain, with only some minor linear interactions.

90 Long short-term memory
Core idea behind LSTM The LSTM does have the ability to remove or add information to the cell state, carefully regulated by structures called gates. Gates are a way to optionally let information through. They are composed out of a sigmoid neural net layer and a pointwise multiplication operation.

91 Long short-term memory
Core idea behind LSTM The sigmoid layer outputs numbers between zero and one, describing how much of each component should be let through. A value of zero means “let nothing through,” while a value of one means “let everything through!

92 Long short-term memory
Step by Step Walk Through of LSTM The first step in our LSTM is to decide what information we’re going to throw away from the cell state. This decision is made by a sigmoid layer called the “forget gate layer.”

93 Long short-term memory
Step by Step Walk Through of LSTM The next step is to decide what new information we’re going to store in the cell state. This has two parts.

94 Long short-term memory
Step by Step Walk Through of LSTM First, a sigmoid layer called the “input gate layer” decides which values we’ll update. Next, a tanh layer creates a vector of new candidate values, 𝐶 𝑡 , that could be added to the state.

95 Long short-term memory
Step by Step Walk Through of LSTM It’s now time to update the old cell state, , into the new cell state The previous steps already decided what to do, we just need to actually do it.

96 Long short-term memory
Step by Step Walk Through of LSTM Finally, we need to decide what we’re going to output.

97 Long short-term memory
Some varients of LSTM One popular LSTM variant, introduced by Gers & Schmidhuber (2000), is adding “peephole connections.”

98 Long short-term memory
Some varients of LSTM One popular LSTM variant, introduced by Gers & Schmidhuber (2000), is adding “peephole connections.”

99 Long short-term memory
Some varients of LSTM Another variation is to use coupled forget and input gates. Instead of separately deciding what to forget and what we should add new information to, we make those decisions together.

100 Long short-term memory
Some varients of LSTM A slightly more dramatic variation on the LSTM is the Gated Recurrent Unit, or GRU, introduced by Cho, et al. (2014). It combines the forget and input gates into a single “update gate.” It also merges the cell state and hidden state, and makes some other changes.

101 Long short-term memory
forget gate unit ( for time step t and cell i ) internal state ( for time step t and cell i ) external input gate ( for time step t and cell i ) output ( for time step t and cell i ) output gate ( for time step t and cell i )

102 Many thanks


Download ppt "Zhu Han University of Houston"

Similar presentations


Ads by Google