simet.metrics.roc_auc.mlp¶
simet.metrics.roc_auc.mlp ¶
RocMLP ¶
RocMLP(in_dim, h1=256, h2=128, p=0.2)
Bases: Module
Two-hidden-layer MLP that outputs a single logit for binary tasks.
Architecture
in_dim → Linear(h1) → ReLU → Dropout(p) → Linear(h2) → ReLU → Dropout(p) → Linear(1) → (logit)
Intended for binary classification / scoring (e.g., ROC-AUC evaluation) using
logits (apply torch.nn.BCEWithLogitsLoss or torch.sigmoid externally).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_dim
|
int
|
Input feature dimension |
required |
h1
|
int
|
Hidden size of the first layer. Defaults to 256. |
256
|
h2
|
int
|
Hidden size of the second layer. Defaults to 128. |
128
|
p
|
float
|
Dropout probability applied after each hidden ReLU. Defaults to 0.2. |
0.2
|
Attributes:
| Name | Type | Description |
|---|---|---|
net |
Sequential
|
The MLP stack producing a single logit. |
Input/Output:
- Input: x of shape (N, D) with D == in_dim.
- Output: Logits of shape (N,) (after squeeze(-1)).
Example
model = RocMLP(in_dim=2048).eval() x = torch.randn(8, 2048) logits = model(x) logits.shape torch.Size([8])
Source code in simet/metrics/roc_auc/mlp.py
38 39 40 41 42 43 44 45 46 47 48 | |
forward ¶
forward(x)
Compute logits for a batch of feature vectors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input tensor of shape |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Logits of shape |
Tensor
|
or use with |
Source code in simet/metrics/roc_auc/mlp.py
50 51 52 53 54 55 56 57 58 59 60 | |