Why input is scaled in tf.nn.dropout in tensorflow?

前端 未结 4 1968
自闭症患者
自闭症患者 2021-01-30 13:31

I can\'t understand why dropout works like this in tensorflow. The blog of CS231n says that, \"dropout is implemented by only keeping a neuron active with some probability

4条回答
  •  旧时难觅i
    2021-01-30 14:03

    Let's say the network had n neurons and we applied dropout rate 1/2

    Training phase, we would be left with n/2 neurons. So if you were expecting output x with all the neurons, now you will get on x/2. So for every batch, the network weights are trained according to this x/2

    Testing/Inference/Validation phase, we dont apply any dropout so the output is x. So, in this case, the output would be with x and not x/2, which would give you the incorrect result. So what you can do is scale it to x/2 during testing.

    Rather than the above scaling specific to Testing phase. What Tensorflow's dropout layer does is that whether it is with dropout or without (Training or testing), it scales the output so that the sum is constant.

提交回复
热议问题