MCPcopy Create free account
hub / github.com/BorealisAI/scaleformer / test

Function test

layers/utils.py:254–276  ·  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

252
253
254def test(model, test_loader, device, verbose=0, lossFn=None,
255 post_proc = lambda args: args):
256
257 model.eval()
258 if lossFn is None:
259 lossFn = nn.MSELoss()
260
261
262 total_loss = 0.
263 predictions = []
264
265 with torch.no_grad():
266 for data, target in test_loader:
267 bs = len(data)
268
269 data, target = data.to(device), target.to(device)
270 output = model(data)
271 output = post_proc(output)
272
273 loss = lossFn(output.view(bs, -1), target.view(bs, -1))
274 total_loss += loss.sum().item()
275
276 return total_loss/len(test_loader.dataset)
277
278
279# Till EoF

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected