nexuml_library.layers.feature.projector¶
nexuml_library.layers.feature.projector
¶
Linear projection layers.
Linear
¶
Bases: LayerDefinition
Multi-layer linear projector with optional activation and normalization.
Attributes:
| Name | Type | Description |
|---|---|---|
target_dim |
int | None
|
Output dimension. If None, uses output_sizes. |
hidden_dim |
int
|
Hidden layer size (for n_layers > 1). |
hidden_dims |
list[int] | None
|
Explicit hidden-layer sizes. When provided, overrides hidden_dim/n_layers for layer construction. |
n_layers |
int
|
Number of linear layers. |
linear_bias |
bool
|
Whether to use bias. |
activation |
str | None
|
Dotted class path, e.g. "torch.nn.GELU". |
normalization |
str | None
|
Dotted class path, e.g. "torch.nn.BatchNorm1d". |
skip_last_activation |
bool
|
Skip activation after the last layer. |
flatten_dims |
tuple[int, int] | None
|
Optional (start, end) dims to flatten before projection. |
Conv1dProjector
¶
Bases: LayerDefinition
Pointwise Conv1d projector for sequence inputs (B, T, C).
Equivalent to Linear but uses Conv1d for better memory access patterns.
Attributes:
| Name | Type | Description |
|---|---|---|
target_dim |
int | None
|
Output channel dimension. If None, uses output_sizes. |
hidden_dim |
int
|
Hidden size for multi-layer projectors. |
n_layers |
int
|
Number of projection layers. |
bias |
bool
|
Whether to use bias. |
activation |
str | None
|
Dotted class path for activation. |
normalization |
str | None
|
Dotted class path for normalization. |
LowRankProjector
¶
Bases: LayerDefinition
Low-rank factorized projection W ≈ U @ V.
Reduces parameters from O(CD) to O((C+D)r) when r << min(C, D).
Attributes:
| Name | Type | Description |
|---|---|---|
target_dim |
int | None
|
Output dimension. If None, uses output_sizes. |
rank |
int
|
Bottleneck rank. |
bias |
bool
|
Whether to use bias. |
activation |
str | None
|
Optional activation between U and V. |