Keras:在训练和测试阶段如何使用辍学? [英] Keras: how to use dropout at train and test phase?

查看:157
本文介绍了Keras:在训练和测试阶段如何使用辍学?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Keras的训练和测试阶段可以使用辍学吗?

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

就像这里描述的那样: https://github.com/soumith/ganhacks#17-use-dropouts-in-g-in-both-train-and-test-phase

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

推荐答案

当然,您可以在调用 Dropout层时将training参数设置为True.这样,辍学将同时应用于培训和测试阶段:

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

这篇关于Keras:在训练和测试阶段如何使用辍学?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆