PaySim-Fraud / src /models /model.py
Nickanas's picture
Upload 24 files
71c85a4 verified
Raw History Blame Contribute Delete
803 Bytes
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)