Keras: how to use dropout at train and test phase?

2019-08-20 04:37发布

Is it possible to use dropout at train and test phase in Keras?

Like described here: https://github.com/soumith/ganhacks#17-use-dropouts-in-g-in-both-train-and-test-phase

2条回答
forever°为你锁心
2楼-- · 2019-08-20 05:11

You don't want to use Dropout in Test phase.

Dropout is a technique used to force neurons to be more independent each other: each neuron will be deactivate with the probability that you set, but only in the training phase.

In the Test phase you keep all the neurons working.

More details here and here

查看更多
手持菜刀,她持情操
3楼-- · 2019-08-20 05:30

Sure, you can set training argument to True when calling the Dropout layer. In this way, dropout would be applied in both training and test phases:

drp_output = Dropout(rate)(inputs, training=True)  # dropout would be active in train and test phases
查看更多
登录 后发表回答