Tensorflow RNN How To Create Zero State With Various Batch Size?
In this question How do I set TensorFlow RNN state when state_is_tuple=True?: the accepted answer initialize the initial state like this: state_placeholder = tf.placeholder(tf.floa
Solution 1:
cell.zero_state
accepts a scalar tensor.
Get the batch size of the place holder via tf.shape
, then it is done:
B = tf.shape(state_placeholder)[0] # the batch size scalar tensor
initial_state = cell.zero_state(B)
Post a Comment for "Tensorflow RNN How To Create Zero State With Various Batch Size?"