tensorflow: LSTMBlockFusedCell does not support using DropoutWrapper

I am trying to use DropoutWrapper with LSTMBlockFusedCell as follows:

cell = tf.contrib.rnn.LSTMBlockFusedCell(num_units,forget_bias) 
cell = tf.contrib.rnn.DropoutWrapper(cell,dropout)

I get an exception that the LSTMBlockFusedCell is not an RNNCell Message: The parameter cell is not a RNNCell. Which is raised form _like_rnncell during DropoutWrapper initialization.

It is checking for those proprieties on the cell: ““Checks that a given object is an RNNCell by using duck typing.””" conditions = [hasattr(cell, “output_size”), hasattr(cell, “state_size”), hasattr(cell, “zero_state”), callable(cell)] LSTMBlockFusedCell does not have output_size , state_size or zero_state properties.

Should LSTMBlockFusedCell act like RNNCell to allow using various wrappers?

https://stackoverflow.com/questions/46699985/using-tensorflow-dropoutwrapper-with-lstmblockfusedcell

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 11
  • Comments: 16 (13 by maintainers)

Most upvoted comments

Unfortunately, because this is cell is fused in time, adding dropout would require modifying the C++ code that performs the computation to add proper random number generation and dropout. Work in this direction is not planned at the moment but I’ll ping @ekelsen to get his thoughts on feasibility.

What about MultiRNNCell ? I believe this was the whole point of DropoutWraper, so that higher level functions accepting rnn cells can be used.

I agree with @godefv the workaround is ok for dropout wrapper, but you cannot still use it MultiRNNCell and dynamic_rnn

You’re right. This should be sufficiently easy, by adding new input_keep_prob and variational_recurrent args to the constructor. If someone is interested in adding this, I’m happy to review the PR.

On Wed, Dec 6, 2017 at 4:41 PM, xiaoyun wu notifications@github.com wrote:

why? the http://arxiv.org/abs/1409.2329 says the dropout is only applied to input not state, why can we just do a dropout on the input first?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/tensorflow/issues/13649#issuecomment-349823037, or mute the thread https://github.com/notifications/unsubscribe-auth/ABtim5r3LTeI9GwX5GpALXb95gAITbckks5s9zQ6gaJpZM4P2WPu .