MCPcopy Create free account
hub / github.com/ZinYY/TreeLoRA / evaluation

Function evaluation

training/main.py:493–515  ·  view source on GitHub ↗
(model, eval_dataloader)

Source from the content-addressed store, hash-verified

491
492
493 def evaluation(model, eval_dataloader):
494 model.eval()
495 losses = 0
496 for step, batch in enumerate(eval_dataloader):
497 # implementation, batch = {k: v.to(device) for k, v in batch.items()}
498 del batch['sources']
499 batch = to_device(batch, device)
500 with torch.no_grad():
501 # check output
502 outputs = model(**batch)
503
504 loss = outputs.loss
505 losses += loss.float()
506 losses = losses / (step + 1)
507 try:
508 perplexity = torch.exp(losses)
509 except OverflowError:
510 perplexity = float("inf")
511 try:
512 perplexity = get_all_reduce_mean(perplexity).item()
513 except:
514 pass
515 return perplexity
516
517 def get_optimizer(model):
518 # Split weights in two groups, one with weight decay and the other not.

Callers

nothing calls this directly

Calls 3

to_deviceFunction · 0.90
get_all_reduce_meanFunction · 0.90
evalMethod · 0.80

Tested by

no test coverage detected