File size: 803 Bytes
71c85a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import torch.nn as nn


class FraudMLP(nn.Module):
    """Small MLP baseline for flat-row fraud classification.



    Outputs a single logit per row — pair with BCEWithLogitsLoss

    (no sigmoid here; the loss applies it internally).

    """
    def __init__(self, input_dim: int, hidden: int = 64, p_drop: float = 0.3):
        super().__init__()
        self.net = nn.Sequential(
            nn.Linear(input_dim, hidden),
            nn.BatchNorm1d(hidden),
            nn.ReLU(),
            nn.Dropout(p_drop),

            nn.Linear(hidden, hidden // 2),
            nn.BatchNorm1d(hidden // 2),
            nn.ReLU(),
            nn.Dropout(p_drop),

            nn.Linear(hidden // 2, 1),   # single logit
        )

    def forward(self, x):
        return self.net(x)