# Doubt related to Inverted Dropout Technique

Hello,

I actually have few doubts related to dropout technique as follows:

1. Firstly I didnot understand why we divide by the keep_prob (as show in the attached image), what purpose does it serve is something that confuses me.

2. Secondly when we apply dropout technique, why is it difficult to track the cost function graph, as Prof Andrew Ng explains that to run the NN without dropout and see if its working fine and then apply dropout, this part i didnot understand, can any one explain me this in detail pleaseâ€¦

Any help for this is highly appreciated, thank you in advanceâ€¦

Prof Ng explained both those things in the lectures. If you did not understand what he was saying, Iâ€™ll give you my explanation, but then you really should just go back and listen to what he said with this in mind:

For the dividing by `keep_prob`, you are compensating for the fact that you â€śkilledâ€ť `(1 - keep_prob)` percentage of the neurons with dropout. So the next layer will be seeing less total â€śinput activation energyâ€ť unless you compensate by increasing the outputs of the non-killed neurons to compensate for the percentage that you â€śkilledâ€ť. Remember that when we run the trained network to make predictions, there will be no dropout at all. So if the following layers are trained on less input, then they wonâ€™t work as well when they get the full input.

On the question of the cost function, the point is that what dropout does is literally change the architecture of the network. The cost function is a mapping from the inputs to the final scalar cost J and youâ€™ve literally changed the function on each training iteration by changing the architecture of the network by killing some percentage of the neurons. Of course the other point here is that dropout is random and different on every iteration. So from a mathematical p.o.v. itâ€™s a different function on every iteration and the values are not comparable. To be precise you would compute the accuracy at any point in the training by evaluating it with `keep_prob = 1` to disable dropout. Of course thatâ€™s also how you will be using the network once the training is complete, as I mentioned in the previous paragraph. So that gives you a better (more honest) evaluation of the performance of the network.

There have been lots of threads about your first question. E.g. hereâ€™s one. If you read all the way through that one it also discusses the fact that the way Prof Ng has structured this is different (better) than the way they handled the inverted dropout in the original Hinton paper that introduced dropout.

But as I said at the beginning, you really should listen to what Prof Ng says if you missed all the above on the first time through. Iâ€™m not making this stuff up: everything I said above is just me restating something Prof Ng said in the lectures in my own words.

2 Likes

There are several additional interesting and slightly more subtle points in how they have us build dropout in the assignment: as they usually do here, they set the random seed to a fixed value, so that itâ€™s easy for them to write the test cases and the graders. But that means weâ€™re literally dropping the exact same neurons on every iteration, which is not how dropout really works. Hereâ€™s a thread which discusses that point and even includes some experiments.

Then the other point is that if you are just dropping the same neurons every time, isnâ€™t that equivalent to just defining a smaller network to start with and then dispensing with all the dropout business. Maybe, but hereâ€™s a thread which discusses that point a bit more.

1 Like