MCPcopy Create free account
hub / github.com/Anoise/WTFlib / test

Function test

LDPS_Graph/layers/utils.py:229–251  ·  view source on GitHub ↗
(model, test_loader, device, verbose=0, lossFn=None,
        post_proc = lambda args: args)

Source from the content-addressed store, hash-verified

227
228
229def test(model, test_loader, device, verbose=0, lossFn=None,
230 post_proc = lambda args: args):
231
232 model.eval()
233 if lossFn is None:
234 lossFn = nn.MSELoss()
235
236
237 total_loss = 0.
238 predictions = []
239
240 with torch.no_grad():
241 for data, target in test_loader:
242 bs = len(data)
243
244 data, target = data.to(device), target.to(device)
245 output = model(data)
246 output = post_proc(output)
247
248 loss = lossFn(output.view(bs, -1), target.view(bs, -1))
249 total_loss += loss.sum().item()
250
251 return total_loss/len(test_loader.dataset)
252
253
254# Till EoF

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected