Class/Object

org.platanios.tensorflow.api.ops.rnn.attention

Attention

Related Docs: object Attention | package attention

Permalink

abstract class Attention[AS, ASS] extends AnyRef

Base class for attention mechanisms.

Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Attention
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Attention(memory: Output, memorySequenceLengths: Output = null, checkInnerDimensionsDefined: Boolean = true, scoreMaskValue: Output = Float.NegativeInfinity, name: String = "Attention")(implicit evAS: Aux[AS, ASS])

    Permalink

    memory

    Memory to query; usually the output of an RNN encoder. Each tensor in the memory should be shaped [batchSize, maxTime, ...].

    memorySequenceLengths

    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.

    checkInnerDimensionsDefined

    If true, the memory argument's shape is checked to ensure that all but the two outermost dimensions of each tensor are fully defined.

    scoreMaskValue

    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

    Name prefix to use for all created ops.

Abstract Value Members

  1. abstract def alignment(query: Output, previousState: AS): (Output, AS)

    Permalink

    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

    Query tensor.

    previousState

    Previous alignment tensor.

    returns

    Tuple containing the alignment tensor and the next attention state.

  2. abstract def initialState: AS

    Permalink

    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.

  3. abstract def score(query: Output, state: AS): Output

    Permalink

    Computes an alignment score for query.

    Computes an alignment score for query.

    query

    Query tensor.

    state

    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.

    returns

    Score tensor.

    Attributes
    protected
  4. abstract def stateSize: ASS

    Permalink

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. lazy val alignmentSize: Output

    Permalink
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. lazy val batchSize: Output

    Permalink
  7. val checkInnerDimensionsDefined: Boolean

    Permalink

    If true, the memory argument's shape is checked to ensure that all but the two outermost dimensions of each tensor are fully defined.

  8. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. lazy val dataType: types.DataType

    Permalink
  10. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  15. lazy val initialAlignment: Output

    Permalink

    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.

  16. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  17. lazy val keys: Output

    Permalink
  18. val memory: Output

    Permalink

    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, ...].

    Attributes
    protected
  19. val memorySequenceLengths: Output

    Permalink

    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.

    Attributes
    protected
  20. val name: String

    Permalink

    Name prefix to use for all created ops.

  21. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  22. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  23. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  24. def probability(score: Output, state: AS): Output

    Permalink

    Computes alignment probabilities for score.

    Computes alignment probabilities for score.

    score

    Alignment score tensor.

    state

    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.

    returns

    Alignment probabilities tensor.

    Attributes
    protected
  25. val scoreMaskValue: Output

    Permalink

    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.

  26. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  27. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  28. lazy val values: Output

    Permalink
  29. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped