fishy.models.deep.srmlp¶
SRMLP: Sign-Random Gated MLP. Features the SRNorm (Sign-Random Norm) layer which applies a fixed random projection and sign-bit quantization to the spectral features.
Classes
- class fishy.models.deep.srmlp.GatedMLPBlock(dim: int, dropout: float = 0.3)[source]¶
Bases:
ModuleStandard SwiGLU Gating Block.
- __init__(dim: int, dropout: float = 0.3)[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.srmlp.SRMLP(input_dim: int, output_dim: int, hidden_dim: int = 512, num_layers: int = 4, dropout: float = 0.3, **kwargs)[source]¶
Bases:
ModuleSign-Random Gated MLP. Combines SRNorm with high-capacity Gated MLP blocks.
- __init__(input_dim: int, output_dim: int, hidden_dim: int = 512, num_layers: int = 4, dropout: float = 0.3, **kwargs) None[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x: Tensor, return_attention: bool = False, *args, **kwargs) Tensor | Tuple[Tensor, List][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.srmlp.SRNorm(dim: int, projection_dim: int = None)[source]¶
Bases:
ModuleSign-Random Normalization. Projects input to a random subspace and applies the sign function. This acts as a powerful non-linear regularizer and dimensionality compressor.
- __init__(dim: int, projection_dim: int = 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.
s