MCPcopy Create free account
hub / github.com/THUDM/GLM / classify_evaluate

Function classify_evaluate

tasks/language_model/finetune.py:119–135  ·  view source on GitHub ↗

Evaluation.

(model, dataloader, example_dict, args)

Source from the content-addressed store, hash-verified

117
118
119def 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
138def evaluate(model, dataloader, eval_metric, args):

Callers

nothing calls this directly

Calls 2

lm_forward_stepFunction · 0.85
extendMethod · 0.80

Tested by

no test coverage detected