Evaluation.
(model, dataloader, example_dict, args)
| 117 | |
| 118 | |
| 119 | def classify_evaluate(model, dataloader, example_dict, args): |
| 120 | """Evaluation.""" |
| 121 | # Turn on evaluation mode which disables dropout. |
| 122 | model.eval() |
| 123 | predictions, labels, examples = [], [], [] |
| 124 | with torch.no_grad(): |
| 125 | # For all the batches in the dataset. |
| 126 | for iteration, batch in enumerate(dataloader): |
| 127 | # Forward evaluation. |
| 128 | output, _, _ = lm_forward_step(batch, model, args, None, [], eval_metric='classify') |
| 129 | uid_list = batch['uid'] |
| 130 | example_batch = [example_dict[uid] for uid in uid_list] |
| 131 | predictions.extend(output.long().tolist()) |
| 132 | label = batch['label'].tolist() |
| 133 | labels.extend(label) |
| 134 | examples.extend(example_batch) |
| 135 | return predictions, labels, examples |
| 136 | |
| 137 | |
| 138 | def evaluate(model, dataloader, eval_metric, args): |
nothing calls this directly
no test coverage detected