org.platanios.tensorflow.api.ops.rnn.attention
Memory to query; usually the output of an RNN encoder. Each tensor in the memory
should be shaped [batchSize, maxTime, ...]
.
Sequence lengths for the batch entries in the memory. If provided, the memory tensor rows are masked with zeros for values past the respective sequence lengths.
If true
, the memory
argument's shape is checked to ensure that all but the
two outermost dimensions of each tensor are fully defined.
Scalar tensor containing the mask value to use for the attention scores before
passing them to probability
. Defaults to negative infinity. Note that this
value is only used if memorySequenceLengths
is not null
.
Name prefix to use for all created ops.
Computes an alignment tensor given the provided query and previous alignment tensor.
Computes an alignment tensor given the provided query and previous alignment tensor.
The previous alignment tensor is important for attention mechanisms that use the previous alignment to calculate the attention at the next time step, such as monotonic attention mechanisms.
TODO: Figure out how to generalize the "next state" functionality.
Query tensor.
Previous alignment tensor.
Tuple containing the alignment tensor and the next attention state.
Initial state value.
Initial state value.
This is important for attention mechanisms that use the previous alignment to calculate the alignment at the next time step (e.g., monotonic attention).
The default behavior is to return the same output as initialAlignment
.
Computes an alignment score for query
.
Computes an alignment score for query
.
Query tensor.
Current attention mechanism state (defaults to the previous alignment tensor). The data type of
this tensor matches that of values
and its shape is [batchSize, alignmentSize]
, where
alignmentSize
is the memory's maximum time.
Score tensor.
If true
, the memory
argument's shape is checked to ensure that all but the
two outermost dimensions of each tensor are fully defined.
Initial alignment value.
Initial alignment value.
This is important for attention mechanisms that use the previous alignment to calculate the alignment at the next time step (e.g., monotonic attention).
The default behavior is to return a tensor of all zeros.
Memory to query; usually the output of an RNN encoder.
Memory to query; usually the output of an RNN encoder. Each tensor in the memory
should be shaped [batchSize, maxTime, ...]
.
Sequence lengths for the batch entries in the memory.
Sequence lengths for the batch entries in the memory. If provided, the memory tensor rows are masked with zeros for values past the respective sequence lengths.
Name prefix to use for all created ops.
Computes alignment probabilities for score
.
Computes alignment probabilities for score
.
Alignment score tensor.
Current attention mechanism state (defaults to the previous alignment tensor). The data type of
this tensor matches that of values
and its shape is [batchSize, alignmentSize]
, where
alignmentSize
is the memory's maximum time.
Alignment probabilities tensor.
Scalar tensor containing the mask value to use for the attention scores before
passing them to probability
.
Scalar tensor containing the mask value to use for the attention scores before
passing them to probability
. Defaults to negative infinity. Note that this
value is only used if memorySequenceLengths
is not null
.
Base class for attention mechanisms.