-
Notifications
You must be signed in to change notification settings - Fork 74k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RNNCellDropoutWrapper applies dropout on the LSTM c state #33690
Comments
For keras LSTM cell, it by default support dropout. You can use param dropout or recurrent dropout for that. The DropoutWrapper is not expected to be used with keras cells. I am going to add an error message when keras lstm cell is used with dropout wrapper. |
See #33690 for details. PiperOrigin-RevId: 277171614 Change-Id: I9925801a2b0c055c595ff20ecf063d6dd876e18e
Is there any reason why The Furthermore, dropout in |
Sorry for the very late reply, I was at TF world last few days. The dropout_wrapper was ported from v1 tf.nn.rnn API, and it has duplicated functionality wrt to existing keras API. We port all the wrappers since they provide some values to user, but we would prefer user to rely on the keras API since they are better integrated. For this particular issue, the fix isn't very straight forward, since the keras lstm cell only returns list as [h, c]. We could check the cell type when it is passed in, but it possible to have the cell being wrapped by other wrapper, etc. If you have other proposal, feel free to send a PR and I would be happy to review it. Thanks. |
Thanks for the reply, @qlzh727. Btw, above I was saying that not all functionalities of DropoutWrapper have been ported in TF2.0/LSTMCell. It seems that |
Sorry for the late reply. I will take a look for the issue you referred. For the variational dropout, the default value is False in DropoutWrapper. However, I would expect most of the user to use True value. The reason to have False by default is being defensive and not changing user's code when adding new flags. You can check the paper for that, and see the performance/accuracy comparison there. On keras side, we are using variational dropout by default, since we believe this is better than the non-variational version. We didn't expose the knob to user to control it based on the consideration for API complexity and ease of use. Also for the output dropout, it can be easily achieved by adding a dropout layer to the output tensor. |
Thanks again, @qlzh727 |
System information
Describe the current behavior
The
_call_wrapped_cell
method of theDropoutWrapperBase
class applies dropout on bothc
andh
states of an LSTM cell. Its default method to determine if a state should take dropout,_default_dropout_state_filter_visitor
, only works correctly with LSTM states packed as aLSTMStateTuple
namedtuple. This was fine in TensorFlow 1.x, where the LSTM state is passed around as aLSTMStateTuple
. However, in TensorFlow 2.0 the state is a Python tuple, and the method returnsTrue
for both substates.Describe the expected behavior
Exclude the LSTM
c
state from the list of dropout candidates.The text was updated successfully, but these errors were encountered: