Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

时间:2021-05-19 15:57:05

Tuning process

下图中的需要tune的parameter的先后顺序, 红色>黄色>紫色,其他基本不会tune.

先讲到怎么选hyperparameter, 需要随机选取(sampling at random)

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks  

随机选取的过程中,可以采用从粗到细的方法逐步确定参数

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

有些参数可以按照线性随机选取, 比如 n[l]

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

但是有些参数就不适合线性的sampling at radom, 比如 learning rate α,这时可以用 log

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

Andrew 很幽默的讲到了两种选参数的实际场景 pandas vs caviar. pandas approach 一般用在你的算力不够时候,要持续几天的training.

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

Batch norm

我们知道对input layer 做 normalizing, 其实对每一层的输入都可以做normalizing, 这就是 batch norm. 做batch norm 时,有对 activation后的结果做norm 的,也有对activation 前的结果 z 做batch norm 的,这里讲的是后一种,对z 做norm.

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

为什么Batch Norm 起作用呢?

先看下下面图讲到的convariate shift,如果traing set 的distribution 变了,就应该重新train model. 同样,对NN的每一层也有类似的问题.

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

Andrew讲到batch norm 是为了尽量使得不同layer decouple,这样相互影响就要小一点,整个NN比较稳定.

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

Batch norm 还有regularization 的作用,但是这个算法主要不是做这个的. 不建议专门用它来做regularization.

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

对 test set 求 μ, σ2, 采用了不一样的方法,就是基于签名mini-batch set 求出来的μ, σ2 应用exponetially weighted average 求平均值. 它和logistic regression 一样,decision boudary 是线性的.

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

Softmax Regression

Softmax regression 就是 logistic regression 的generaliazation 版本, 它可以用在multi-class clarification 问题上。和logistic regression 一样,decision boudary 都是线性的. 如果要使得decison boudary 是非线性的就需要deep network.

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks

Programing framework

TensorFlow by google, an example

  Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks