Add dropout and recurrent_dropout to CuDNNLSTM and CuDNNGRU
See original GitHub issueNative Keras GRU and LSTM layers support dropout
and recurrent_dropout
, but their CuDNN-accelerated counterparts, CuDNNLSTM and CuDNNGRU, do not. It might be good to add these features. Although CuDNN RNNs do not support dropout natively, it seems to be possible to implement it outside of CuDNN. At least TensorFlow is capable of that. In Keras dropout can be applied either on inputs (dropout
), which should be straightforward, or on previous hidden state (recurrent_dropout
). I’m not sure if the latter might be possible, tough.
The reason is using CuDNN RNN implementation for fast training and allow dropout regularization at the same time.
Please comment if this makes sense or it is wanted. I’d be happy to try implementing that. Thanks.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:38
- Comments:30 (3 by maintainers)
Top Results From Across the Web
How to add recurrent dropout to CuDNNGRU or CuDNNLSTM ...
CuDNNLSTM and CuDNNGRU are LSTM and GRU layers that are compatible with CUDA. The main advantage is that they are 10 times faster...
Read more >tf.compat.v1.keras.layers.CuDNNLSTM | TensorFlow v2.11.0
Initializer for the recurrent_kernel weights matrix, used for the linear transformation of the recurrent state.
Read more >unknown layer cudnnlstm, cudnngru on cpu, no opkernel was ...
However they lack some of the beauty of the LSTM or GRU layers in Keras, namely the possibility to pass dropout or recurrent...
Read more >Python Examples of keras.layers.CuDNNLSTM
def create(inputtokens, vocabsize, units=16, dropout=0, embedding=32): input_ ... CuDNNLSTM elif self.rnn_type=="CuDNNGRU": layer_cell = CuDNNGRU else: ...
Read more >Recurrent layers - Keras
Keras API reference / Layers API / Recurrent layers. Recurrent layers. LSTM layer · GRU layer · SimpleRNN layer · TimeDistributed layer ·...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
This was would be tremendously helpful to many, many people. Not being able to use dropout often renders CuDNN layers virtually useless for training smaller datasets.