...menustart
- MIT S6191, Deep Learning
- Lecture 1 : Intro
- Lecture 2 : Sequence Modeling with Neural Networks
- Lecture 3: Deep Computer Vision
- Lecture 6 :
...menuend
http://introtodeeplearning.com/schedule.html
- Why Deep Learning ?
- Deep learning is powerful because it is able to learn powerful feature representations in an unsupervised manner.
- How do we build neural networks with perceptrons ?
- Stochastic Gradient Descent (SGD)
- the loss function is with respect to every training sample
- while for batch Gradient Descent , the loss function is with respect to the whole training set.
- Calculating the Gradient: Backpropagation
- Loss function can be difficult to optimize
- How to Choose Learning Rate?
- Small Learning Rate
- many iterations unitl convergence
- trapping in local minima
- Large Learning Rate
- overshooting
- Small Learning Rate
- How to deal with this?
- Try lots of different learning rates to see what is ‘just right’
- time-consuming and may not be the best use of our resources
- Do something smarter : Adaptive Learning Rate
- no fixed learning rate
- gonna consider learning rates that can adapt and change based on how the learning is going
- Try lots of different learning rates to see what is ‘just right’
- How to Choose Learning Rate?
- Adaptive Learning Rate
- Learning rate is no longer fixed
- Can be made larger or smaller depending on:
- how large gradient is
- how fast learning is happening
- size of particular weights
- etc
- Adaptive Learning Rate Algorithms
- ADAM, Momentum, NAG, Adagrad, Adadelta, RMSProp
- Escaping Saddle Points
- Stochastic Gradient Descent issue
- we are only looking at one example to get each gradient so this is a pretty non consistent and kind of stochastic representation of our loss and gradient.
- it's not a very reliable and consistent learning singal
- Minibatches Reduce Gradient Variance
- more accurate estimate of gradient
- Advantages of Minibatches
- More accurate estimation of gradient
- Smoother convergence
- Allows for larger learning rates
- Minibatches lead to fast training!
- Can parallelize computation + achieve significant speed increases on GPU’s
- More accurate estimation of gradient
- Sometimes NNet can be a little bit too powerful and they can either overfit or maybe memorize training examples.
- Regularization Techniques
- Dropout
- During training, randomly set some activations (hidden layer nodes) to 0
- Typically ‘drop’ 50% of activations in layer
- Forces network to not rely on any 1 node
- that is , choose random nodes and remove them from the network. and we compute our loss and we do gradient updates
- and essentially what we're doing here is we're making each of our nodes not very reliable. We want our network to not rely too much on any one node.
- During training, randomly set some activations (hidden layer nodes) to 0
- Early Stopping
- Don’t give the network time to overfit
- when you reach a point at which the training accuracy goes up, but the validation actually goes down. and it continues to go down.
- early stopping essentially is just kind of keep track of how well the validation is doing and you just kind of stopping the training once it starts doing worse.
- it is really simple technique and it works really well in practice.


- Weight Regularization
- Large (big) weights typically mean model is overfitting
- big weights means rely too much on nodes??
- Add the size of the weights to our loss function
- Perform well on task + keep weights small
- J(θ) = loss + λ·∑ⱼ(θⱼ)²
- Large (big) weights typically mean model is overfitting
- ...many more
- Dropout
What if each training sample itself consisted of multiple data points, and those data points were somehow related or dependent on each other.
- What is a sequence?
- sentence : “I took the dog for a walk this morning.”
- a sentence consists of multiple words, and each words is dependent on other words in the sentence
- function : sinx
- speech waveform
- sentence : “I took the dog for a walk this morning.”
- Successes of deep models
- Machine translation
- Question Answering
- idea: represent a sequence as a bag of words
- problem: bag of words does not preserve order
- “The food was good, not bad at all.”
- vs
- “The food was bad, not good at all.”
- they are completely different semantics meetings but in their bag of words representation, they would be exactly the same because they contain the same set of words.
- idea: maintain an ordering within feature vector
- problem: hard to deal with different word orders
A way to solve it is by sharing parameters across our sequence. So once we learn something like the fact that "on Monday" represents a time or a setting we can resus that fact later on in the sentence.
- idea: markov models
- problem: we can’t model long-term dependencies
- markov assumption: each state depends only on the last state.
- This is a kind of problem for complex sequences like natural language or speach waveforms.
- “In France, I had a great time and I learnt some of the
____language.” - We need information from the far past and future to accurately guess the correct word.
- “In France, I had a great time and I learnt some of the
- let’s turn to recurrent neural networks! (RNNs)
- to maintain word order
- to share parameters across the sequence
- to keep track of long-term dependencies
- RNN
- the key difference is that each of those hidden units is just doing something a little bit different.
- each hidden unit in addtion to computing a function of the input , also computes a function of its own previous output
- in this way it's able to keep track of things that have happened in the past.
- RNNS remember their previous state:
- “unfolding” the RNN across time:

- the orange circle is the same hidden unit just at different points in time.
- at each time step it takes in a new word and it calculates the next output of the hidden unit based on that new word and its own previous output. And it just continues doing this throughout time. -- I say time but it also means, if we have a sentence , like the word in the sentence or the point that we're in the sentence.
- notice that W and U stay the same through out the sequence.
- this solves one of the key problem about sharing parameters throughout the sequence.
- sn can contain information from all past timesteps
- solves the problem about remembering information from far back in the sequence.
- possible task: language model
- all the works of shakespeare
- -> language model ->
- KING LEAR: O, if you were a feeble sight, the courtesy of your law, Your sight and several breath, will wear the gods With his heads, and my hands are wonder'd at the deeds, So drop upon your lordship's head, and your opinion Shall be against your honour.

- yᵢ is actually a probability distribution over possible next words, aka a softmax
- given that I'm at the start of a sentence what is the most likely next word ? alas
- now given that I've seen "alas" what's the most likely next word ? my
- given that I've seen "alas my" what's the most likely next word ? honor.
- all the works of shakespeare
- possible task: classification (i.e. sentiment)
- possible task: machine translation
- remember: backpropagation
- take the derivative (gradient) of the loss with respect to each parameter
- shift parameters in the opposite direction in order to minimize loss
- we have a loss at each timestep:
- we sum the losses across time:
- loss at time t = Jt(Θ)
- total loss = J(Θ) = ∑ Jt(Θ)
- what are our gradients?
- let’s try it out for W with the chain rule:
- how does s₂ depend on W?
- backpropagation through time:
It is because of this annoying problem called the vanishing gradient.
-
problem: vanishing gradient
- the term ∂s₂/∂sk itself is also a chain rule.

- as the gap between timesteps gets bigger, this product gets longer and longer!
- what are each of these ∂ terms ?
- we’re multiplying a lot of small numbers together.
- what this means is that errors due to further back timesteps have increasingly smaller gradients
- so parameters become biased to capture shorter-term dependencies.
- “In France, I had a great time and I learnt some of the
____language.”- our parameters are not trained to capture long-term dependencies, so the word we predict will mostly depend on the previous few words, not much earlier ones
-
solution #1: activation functions
-
solution #2: initialization
- weights initialized to identity matrix , biases initialized to zeros
- prevents W from shrinking the gradients
-
solution #3: gated cells
-
solution #3: more on LSTM
- LSTM is very similar to a recurrent cell , it takes in a cell state and output the next cell state based on that.
- but there is just some additional steps in between.
- forget irrelevant parts of previous state
- for example, if I'm modeling a sentence and I see a new subject I might choose to forget I might choose to forget the old subject.Because I know that the next verb will be conjugated according to the new subject.
- selectively update cell state values
- if the new subject is singular and masculine 男性单数 I might want to update my cell state so it knows that. Because I know that will be relevant information to the next verb that I ought to conjugating the next verb.
- output certain parts of cell state
- there might be certain things that I want to keep in the cell state that are not relevant to the output at this time.
- so say I have the word "France" in my cell state , I might want to keep it there but not output it , because it won't be relevant to this current word that I'm predicting. But it will be relevant at some furture time.
- in this way I'm able to hold on to things without them contributing to the loss at that time step.
- forget irrelevant parts of previous state
-
why do LSTMs help?
- forget gate allows you forgot certain information but also remember it and let it pass through unchanged
- when taking the derivative, f’ is 1 for what we want to keep!
- sⱼ depends on sⱼ₋₁ through addition! (middel step)
- when taking the derivative, not lots of small W terms!
- forget gate allows you forgot certain information but also remember it and let it pass through unchanged
-
in practice: machine translation.
- basic encoder-decoder model
- add LSTM cells
- problem: a fixed-length encoding is limiting
- solution: attend over all encoder states
- we're attending over all of the encoder states
- so the feature vector that's fed in to our decoder , that's telling our decoder what the original sentence was about is not just the last cell state , but a weighted sum of all of the cell states , from the encoder
- if we're decoding the first word , we might choose to put most of the weight on the first cell state from the encoder, because that's most probably what's most relevant.
- then we're decoding the second word, we might put most of the weight on the second cell state , but maybe a little bit on the first cell state.
- and so on and so forth.
- and those weight that we use to create this weighted sum are just learned along with the rest of our parameters in the model using backpropagation. They just come part of our data.
- now we can model sequences!
- why recurrent neural networks?
- building models for language, classification, and machine translation
- training them with backpropagation through time
- solving the vanishing gradient problem with activation functions, initialization, and gated cells (like LSTMs)
- using attention mechanisms
- and there’s lots more to do!
- extending our models to timeseries + waveforms
- complex language models to generate long text or books
- language models to generate code
- controlling cars + robots
- predicting stock market trends
- summarizing books + articles
- handwriting generation
- multilingual translation models
- … many more!
- MNIST: handwritten digits
- ImageNet: WordNet hierarchy
- CIFAR-10(0): tiny images
- Places: natural scenes
- CNN have a volumn , a 3d volumn.
卷积神经网络各个层级结构
- 最左边是数据输入层
- 对数据做一些处理,比如去均值(把输入数据各个维度都中心化为0,避免数据过多偏差,影响训练效果), 归一化(把所有的数据都归一到同样的范围),PCA/白化等等。
- CNN只对训练集做“去均值”这一步
- INPUT [32x32x3] will hold the raw pixel values of the image, in this case an image of width 32, height 32, and with three color channels R,G,B
- 中间是
- CONV:卷积计算层,线性乘积 求和
- CONV layer will compute the output of neurons that are connected to local regions in the input, each computing a dot product between their weights and a small region they are connected to in the input volume. This may result in volume such as [32x32x12] if we decided to use 12 filters.
- RELU:激励层
- RELU layer will apply an elementwise activation function, such as the max(0,x) thresholding at zero. This leaves the size of the volume unchanged ([32x32x12]).
- POOL:池化层,简言之,即取区域平均或最大
- POOL layer will perform a downsampling operation along the spatial dimensions (width, height), resulting in volume such as [16x16x12].
- CONV:卷积计算层,线性乘积 求和
- 最右边是
- FC:全连接层
- 对 图像(不同的数据窗口数据) 和 滤波矩阵 做内积的操作就是所谓的『卷积』操作
- 滤波矩阵是 一组固定的权重:因为每个神经元的多个权重固定,所以又可以看做一个恒定的滤波器filter
- The parameters on a each filter are spatially “shared”
- (if a feature is useful in one place, it’s useful elsewhere)
- filter
- 不同的滤波器filter会得到不同的输出数据
- 卷积参数
- 卷积过程
What CNNs are is a composition of these filters.
- layer1 are very primitive filter -- edges
- layer2
- then you start composing those features together for higher and higher order representation of features to form corners -- in this case parts of face
- layers : entire faces.
- Pooling is an operation that reduces the size of the input and the output. and there is most importantly no learnable weights on this operation.
- pool 就是 取区域平均或最大(max pool)
- sigmoid 在实际梯度下降中 容易饱和、造成终止梯度传递。且没有0中心化。
- ReLU的优点是收敛快,求梯度简单。
- 所以sigmoid 一般只用于 全链接层
- the output is the Q value : Q(s,a)
- Restrictive Assumptions
- Handles long horizons poorly
- Requires a simulator












































