# Improving Deep Neural Networks: Hyperparameter Tuning, Regularization and Optimization

In the second course of the Deep Learning Specialization, you will open the deep learning black box to understand the processes that drive performance and generate good results systematically.

By the end, you will learn the best practices to train and develop test sets and analyze bias/variance for building deep learning applications; be able to use standard neural network techniques such as initialization, L2 and dropout regularization, hyperparameter tuning, batch normalization, and gradient checking; implement and apply a variety of optimization algorithms, such as mini-batch gradient descent, Momentum, RMSprop and Adam, and check for their convergence; and implement a neural network in TensorFlow. The Deep Learning Specialization is our foundational program that will help you understand the capabilities, challenges, and consequences of deep learning and prepare you to participate in the development of leading-edge AI technology. It provides a pathway for you to gain the knowledge and skills to apply machine learning to your work, level up your technical career, and take the definitive step in the world of AI.

Enroll Now: Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization

## Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization (Week 1) Quiz

### Practical aspects of deep learning :

1. If you have 10,000,000 examples, how would you split the train/dev/test set?
•  98% train . 1% dev . 1% test
•  60% train . 20% dev . 20% test
•  33% train . 33% dev . 33% test

1. The dev and test set should:
•  Come from the same distribution
•  Come from different distributions
•  Be identical to each other (same (x,y) pairs)
•  Have the same number of examples

1. If your Neural Network model seems to have high bias, what of the following would be promising things to try? (Check all that apply.)
•  Increase the number of units in each hidden layer
•  Get more training data
•  Make the Neural Network deeper
•  Get more test data

1. If your Neural Network model seems to have high variance, what of the following would be promising things to try?
•  Make the Neural Network deeper
•  Get more training data
•  Get more test data
•  Increase the number of units in each hidden layer

1. You are working on an automated check-out kiosk for a supermarket, and are building a classifier for apples, bananas and oranges. Suppose your classifier obtains a training set error of 0.5%, and a dev set error of 7%. Which of the following are promising things to try to improve your classifier? (Check all that apply.)
•  Increase the regularization parameter lambda
•  Decrease the regularization parameter lambda
•  Get more training data
•  Use a bigger neural network

1. What is weight decay?
•  A technique to avoid vanishing gradient by imposing a ceiling on the values of the weights.
•  A regularization technique (such as L2 regularization) that results in gradient descent shrinking the weights on every iteration.
•  The process of gradually decreasing the learning rate during training.
•  Gradual corruption of the weights in the neural network if it is trained on noisy data.

1. What happens when you increase the regularization hyperparameter lambda?
•  Weights are pushed toward becoming smaller (closer to 0)
•  Weights are pushed toward becoming bigger (further from 0)
•  Doubling lambda should roughly result in doubling the weights
•  Gradient descent taking bigger steps with each iteration (proportional to lambda)

1. With the inverted dropout technique, at test time:
•  You apply dropout (randomly eliminating units) and do not keep the 1/keep_prob factor in the calculations used in training
•  You do not apply dropout (do not randomly eliminate units) and do not keep the 1/keep_prob factor in the calculations used in training
•  You do not apply dropout (do not randomly eliminate units), but keep the 1/keep_prob factor in the calculations used in training.
•  You apply dropout (randomly eliminating units) but keep the 1/keep_prob factor in the calculations used in training.

1. Increasing the parameter keep_prob from (say) 0.5 to 0.6 will likely cause the following: (Check the two that apply)
•  Increasing the regularization effect
•  Reducing the regularization effect
•  Causing the neural network to end up with a higher training set error
•  Causing the neural network to end up with a lower training set error
1. Which of these techniques are useful for reducing variance (reducing overfitting)? (Check all that apply.)
•  L2 regularization
•  Xavier initialization
•  Dropout
•  Data augmentation

1. Why do we normalize the inputs x?
•  Normalization is another word for regularization–It helps to reduce variance
•  It makes it easier to visualize the data
•  It makes the cost function faster to optimize
•  It makes the parameter initialization faster

## Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization (Week 2) Quiz

### Optimization algorithms :

1. Which notation would you use to denote the 3rd layer’s activations when the input is the 7th example from the 8th minibatch?

•  One iteration of mini-batch gradient descent (computing on a single mini-batch) is faster than one iteration of batch gradient descent.Which of these statements about mini-batch gradient descent do you agree with?
•  Training one epoch (one pass through the training set) using mini-batch gradient descent is faster than training one epoch using batch gradient descent.

• You should implement mini-batch gradient descent without an explicit for-loop over different mini-batches, so that the algorithm processes all mini-batches at the same time (vectorization).

1. Why is the best mini-batch size usually not 1 and not m, but instead something in between?
•  If the mini-batch size is 1, you end up having to process the entire training set before making any progress.

•  If the mini-batch size is m, you end up with stochastic gradient descent, which is usually slower than mini-batch gradient descent.

•  If the mini-batch size is m, you end up with batch gradient descent, which has to process the whole training set before making progress.

•  If the mini-batch size is 1, you lose the benefits of vectorization across examples in the mini-batch.

1. 4. Suppose your learning algorithm’s cost J, plotted as a function of the number of iterations, looks like this:
Which of the following do you agree with?
•  If you’re using mini-batch gradient descent, something is wrong. But if you’re using batch gradient descent, this looks acceptable.
•  If you’re using mini-batch gradient descent, this looks acceptable. But if you’re using batch gradient descent, something is wrong. Whether you’re using batch gradient descent or mini-batch gradient descent, something is wrong.
•  Whether you’re using batch gradient descent or mini-batch gradient descent, this looks acceptable.
•

1. Suppose the temperature in Casablanca over the first three days of January are the same:

Jan 1st: $\inline&space;\large&space;\theta_1&space;=&space;10^{\circ}&space;C$

Jan 2nd: $\inline&space;\large&space;\theta_2&space;=&space;10^{\circ}&space;C$

(We used Fahrenheit in lecture, so will use Celsius here in honor of the metric world.)
Say you use an exponentially weighted average with to track the temperature: $\inline&space;\large&space;v_0=0,\&space;v_t=\beta&space;v_{t-1}&space;+&space;(1-\beta)\theta_t$. If $\inline&space;\large&space;v_2$ is the value computed after day 2 without bias correction, and is the value you compute with bias correction. What are these values?

(You might be able to do this without a calculator, but you don’t actually need one. Remember what is bias correction doing.)

1. Which of these is NOT a good learning rate decay scheme? Here, t is the epoch number.

1. You use an exponentially weighted average on the London temperature dataset. You use the following to track the temperature: $\inline&space;\large&space;v_t&space;=&space;\beta&space;v_{t-1}&space;+&space;(1-\beta)&space;\theta_t$. The red line below was computed using $\inline&space;\large&space;\beta&space;=&space;0.9$. What would happen to your red curve as you vary β? (Check the two that apply)

•  Decreasing β will shift the red line slightly to the right.

•  Increasing β will shift the red line slightly to the right.
True, remember that the red line corresponds to β=0.9. In lecture we had a green line $$\beta = 0.98) that is slightly shifted to the right. • Decreasing β will create more oscillation within the red line. True, remember that the red line corresponds to β=0.9. In lecture we had a yellow line$$\beta = 0.98 that had a lot of oscillations.

•  Increasing β will create more oscillations within the red line.

1. Consider this figure:

These plots were generated with gradient descent; with gradient descent with momentum (β = 0.5) and gradient descent with momentum (β = 0.9). Which curve corresponds to which algorithm?
•  (1) is gradient descent with momentum (small β), (2) is gradient descent with momentum (small β), (3) is gradient descent

•  (1) is gradient descent. (2) is gradient descent with momentum (large β) . (3) is gradient descent with momentum (small β)

•  (1) is gradient descent with momentum (small β). (2) is gradient descent. (3) is gradient descent with momentum (large β)

•  (1) is gradient descent. (2) is gradient descent with momentum (small β). (3) is gradient descent with momentum (large β)
1. Suppose batch gradient descent in a deep network is taking excessively long to find a value of the parameters that achieves a small value for the cost function $\inline&space;\large&space;J&space;(W^{[1]},b^{[1]},&space;.&space;.&space;.&space;,W^{[L]},b^{[L]})$. Which of the following techniques could help find parameter values that attain a small value for J? (Check all that apply)

•  Try initializing all the weights to zero

•  Try better random initialization for the weights

•  Try tuning the learning rate α

•  The learning rate hyperparameter α in Adam usually needs to be tuned.

•  Adam should be used with batch gradient computations, not with mini-batches.

## Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization (Week 3) Quiz

### Hyperparameter tuning, Batch Normalization, Programming Frameworks :

1. If searching among a large number of hyperparameters, you should try values in a grid rather than random values, so that you can carry out the search more systematically and not rely on chance. True or False?
•  True

•  False

1. Every hyperparameter, if set poorly, can have a huge negative impact on training, and so all hyperparameters are about equally important to tune well. True or False?
•  True

•  False
Yes. We’ve seen in lecture that some hyperparameters, such as the learning rate, are more critical than others.

1. During hyperparameter search, whether you try to babysit one model (“Panda” strategy) or train a lot of models in parallel (“Caviar”) is largely determined by:
•  Whether you use batch or mini-batch optimization

•  The presence of local minima (and saddle points) in your neural network

•  The amount of computational power you can access

•  The number of hyperparameters you have to tune

1. If you think β (hyperparameter for momentum) is between on 0.9 and 0.99, which of the following is the recommended way to sample a value for beta?
• r = np.random.rand()
beta = r*0.09 + 0.9


• r = np.random.rand()
beta = 1-10**(- r - 1)


• r = np.random.rand()
beta = 1-10**(- r + 1)


• r = np.random.rand()
beta = r*0.9 + 0.09

1. Finding good hyperparameter values is very time-consuming. So typically you should do it once at the start of the project, and try to find very good hyperparameters so that you don’t ever have to revisit tuning them again. True or false?
•  True

•  False

1. In batch normalization as presented in the videos, if you apply it on the lth layer of your neural network, what are you normalizing?

1. In the normalization formula $\inline&space;\dpi{150}&space;\large&space;z_{norm}^{(i)}&space;=&space;\frac{z^{(i)}-\mu}{\sqrt{\mu^2+\varepsilon}}$, why do we use epsilon?
•  To speed up convergence

•  In case μ is too small

•  To have a more accurate normalization

•  To avoid division by zero

1. Which of the following statements about γ and β in Batch Norm are true?
•  β and γ are hyperparameters of the algorithm, which we tune via random sampling.

•  They can be learned using Adam, Gradient descent with momentum, or RMSprop, not just with gradient descent.

1. After training a neural network with Batch Norm, at test time, to evaluate the neural network on a new example you should:

•  If you implemented Batch Norm on mini-batches of (say) 256 examples, then to evaluate on one test example, duplicate that example 256 times so that you’re working with a mini-batch the same size as during training.

1. Which of these statements about deep learning programming frameworks are true?
(Check all that apply)
•  A programming framework allows you to code up deep learning algorithms with typically fewer lines of code than a lower-level language such as Python.

•  Deep learning programming frameworks require cloud-based machines to run.

•  Even if a project is currently open source, good governance of the project helps ensure that the it remains open even in the long term, rather than become closed or modified to benefit only one company.

## Conclution:

We hope you will do well in your Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization Quiz & Assessment Answers by our article. If you think It helps you a little please share it with your friends. And Stay with queryfor.com for any kind of Exam or quiz Answer. We also provide Coursera Quiz answer, Coursehero free Unlock