SNP2P Model Utilities
Overview
This page documents model helper layers that are shared across SNP2P architectures.
Usage and examples
Example: apply a FiLM layer
import torch
from src.model.utils import FiLM
film = FiLM(in_cov=4, hid=16)
covariates = torch.randn(8, 4)
features = torch.randn(8, 10, 16)
modulated = film(features, covariates)
API documentation
- class FiLM
Feature-wise linear modulation layer for injecting covariates.
- class MoEHeadPrediction
Mixture-of-experts head that produces per-position scalar predictions.
- class LayerNormNormedScaleOnly
Layer normalization variant with normalized scaling weights.
- class RMSNorm
Root-mean-square normalization.
- class BatchNorm1d_BatchOnly_NLC
Batch-only normalization over
[B, L, C]inputs.- Parameters:
num_features (int) – Number of feature channels.
eps (float, optional) – Numerical stability term.
momentum (float, optional) – Momentum for running statistics.
affine (bool, optional) – Whether to learn affine parameters.
track_running_stats (bool, optional) – Whether to track running mean/variance.
length (int, optional) – Sequence length used to size running statistics.