MCPcopy Create free account
hub / github.com/DFin/Neural-Network-Visualisation / evaluate

Function evaluate

training/mlp_train.py:115–126  ·  view source on GitHub ↗
(model: nn.Module, loader: DataLoader, device: torch.device)

Source from the content-addressed store, hash-verified

113
114
115def evaluate(model: nn.Module, loader: DataLoader, device: torch.device) -> float:
116 model.eval()
117 correct = 0
118 total = 0
119 with torch.no_grad():
120 for data, target in loader:
121 data, target = data.to(device), target.to(device)
122 output = model(data)
123 pred = output.argmax(dim=1)
124 correct += (pred == target).sum().item()
125 total += target.size(0)
126 return correct / total
127
128
129def parse_hidden_dims(raw: Sequence[int]) -> list[int]:

Callers 2

record_snapshotFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected