tf.contrib.seq2seq.monotonic_attention( p_choose_i, previous_attention, mode )
Defined in tensorflow/contrib/seq2seq/python/ops/attention_wrapper.py
.
Compute monotonic attention distribution from choosing probabilities.
Monotonic attention implies that the input sequence is processed in an explicitly left-to-right manner when generating the output sequence. In addition, once an input sequence element is attended to at a given output timestep, elements occurring before it cannot be attended to at subsequent output timesteps. This function generates attention distributions according to these assumptions. For more information, see Online and Linear-Time Attention by Enforcing Monotonic Alignments
.
p_choose_i
: Probability of choosing input sequence/memory element i. Should be of shape (batch_size, input_sequence_length), and should all be in the range [0, 1].previous_attention
: The attention distribution from the previous output timestep. Should be of shape (batch_size, input_sequence_length). For the first output timestep, preevious_attention[n] should be [1, 0, 0, ..., 0] for all n in [0, ... batch_size - 1].mode
: How to compute the attention distribution. Must be one of 'recursive', 'parallel', or 'hard'.A tensor of shape (batch_size, input_sequence_length) representing the attention distributions for each sequence in the batch.
ValueError
: mode is not one of 'recursive', 'parallel', 'hard'.
© 2018 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/contrib/seq2seq/monotonic_attention