fishy.models.deep.performer¶
Performer model for spectral classification.
Performers use a linear approximation of the attention mechanism via Random Fourier Features (FAVOR+), allowing them to scale to very long sequences.
References: 1. Choromanski, K., et al. (2020). Rethinking Attention with Performers. arXiv:2009.14794.
Classes
- class fishy.models.deep.performer.FastAttention(dim, heads=8, nb_features=64)[source]¶
Bases:
ModuleFAVOR+ Fast Attention implementation.
- __init__(dim, heads=8, nb_features=64)[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(q, k, v)[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.
- class fishy.models.deep.performer.Performer(input_dim: int, output_dim: int, hidden_dim: int = 128, num_layers: int = 4, dropout: float = 0.1, num_heads: int = 8, nb_features: int = 64, **kwargs)[source]¶
Bases:
ModulePerformer model for spectral classification.
- __init__(input_dim: int, output_dim: int, hidden_dim: int = 128, num_layers: int = 4, dropout: float = 0.1, num_heads: int = 8, nb_features: int = 64, **kwargs) None[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x: Tensor) Tensor[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.
- class fishy.models.deep.performer.PerformerLayer(dim, heads=8, nb_features=64, dropout=0.1)[source]¶
Bases:
Module- __init__(dim, heads=8, nb_features=64, dropout=0.1)[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x: Tensor)[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.
Functions
- fishy.models.deep.performer.softmax_kernel(data, projection_matrix, is_query, epsilon=1e-06)[source]¶
Softmax kernel approximation for Performer.
s