如何将经常性辍学添加到Keras中的CuDNNGRU或CuDNNLSTM中

2024-05-20 00:01:39 发布

您现在位置:Python中文网/ 问答频道 /正文

可以通过将其值作为层的参数传递给Keras中的基本LSTM或GRU层,将其应用于该层。在

CuDNNLSTM和CuDNNGRU是与CUDA兼容的LSTM和GRU层。其主要优点是在训练过程中速度提高了10倍。然而,它们缺乏Keras中LSTM或GRU层的一些美丽之处,即传递辍学或经常性辍学值的可能性。在

虽然我们可以直接在模型中添加辍学层,但对于经常性的辍学我们似乎做不到。在

我的问题是:如何在Keras的CuDNNGRU或CuDNNLSTM中增加经常性辍学?


Tags: 模型过程可能性速度cudakeras优点lstm
2条回答

你可以使用核正则化器和递归正则化器来防止过度拟合,我正在使用L2正则化器,我有很好的效果。在

我不认为我们可以拥有它,因为它甚至在低层(即cuDNN)中都没有支持。From François CholletKeras的创建者:

Recurrent dropout is not implemented in cuDNN RNN ops. At the cuDNN level. So we can't have it in Keras.

The dropout option in the cuDNN API is not recurrent dropout (unlike what is in Keras), so it is basically useless (regular dropout doesn't work with RNNs).

Actually using such dropout in a stacked RNN will wreck training.

相关问题 更多 >