src.models.components.attention package§

Submodules§

src.models.components.attention.additive module§

class src.models.components.attention.additive.AdditiveAttention(query_vector_dim, candidate_vector_dim, writer=None, tag=None, names=None)§

Bases: Module

A general additive attention module. Originally for NAML.

forward(candidate_vector)§
Parameters:

candidate_vector – batch_size, candidate_size, candidate_vector_dim

Returns:

(shape) batch_size, candidate_vector_dim

training: bool§

src.models.components.attention.multihead_self module§

class src.models.components.attention.multihead_self.MultiHeadSelfAttention(d_model, num_attention_heads)§

Bases: Module

forward(Q, K=None, V=None, length=None)§

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool§
class src.models.components.attention.multihead_self.ScaledDotProductAttention(d_k)§

Bases: Module

forward(Q, K, V, attn_mask=None)§

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool§

Module contents§