ScaledDotProductAttention#
- class pytorch_forecasting.models.temporal_fusion_transformer.sub_modules.ScaledDotProductAttention(dropout: float = None, scale: bool = True, mask_bias=-1000000000.0)[source]#
Bases:
ModuleScaled Dot-Product Attention.
- Parameters:
dropout (float, optional) – Dropout rate, by default None
scale (bool, optional) – Whether to scale the attention scores, by default True
mask_bias (float, optional) – Bias for the mask in forward, by default -1e9. Set to -float(“inf”) to allow mixed precision training.
Initialize internal Module state, shared by both nn.Module and ScriptModule.
Methods
forward(q, k, v[, mask])Define the computation performed at every call.
- forward(q, k, v, mask=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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.