AttentionLayer#

class pytorch_forecasting.models.timexer.sub_modules.AttentionLayer(attention, d_model, n_heads, d_keys=None, d_values=None)[source]#

Bases: Module

Attention layer that combines query, key, and value projections with an attention mechanism. :param attention: Attention mechanism to use. :type attention: nn.Module :param d_model: Dimension of the model. :type d_model: int :param n_heads: Number of attention heads. :type n_heads: int :param d_keys: Dimension of the keys. Defaults to d_model // n_heads. :type d_keys: int, optional :param d_values: Dimension of the values. Defaults to d_model // n_heads. :type d_values: int, optional

Initialize internal Module state, shared by both nn.Module and ScriptModule.

Methods

forward(queries, keys, values, attn_mask[, ...])

Define the computation performed at every call.

forward(queries, keys, values, attn_mask, tau=None, delta=None)[source]#

Define 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.