mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-25 07:18:58 +06:00
Fix eval_accumulation_steps leading to incorrect metrics (#24756)
Fix eval steps
This commit is contained in:
parent
45025d92f8
commit
7edc33ac7a
@ -3154,7 +3154,7 @@ class Trainer:
|
|||||||
self.control = self.callback_handler.on_prediction_step(args, self.state, self.control)
|
self.control = self.callback_handler.on_prediction_step(args, self.state, self.control)
|
||||||
|
|
||||||
# Gather all tensors and put them back on the CPU if we have done enough accumulation steps.
|
# Gather all tensors and put them back on the CPU if we have done enough accumulation steps.
|
||||||
if args.eval_accumulation_steps is not None and (step + 1) % args.eval_accumulation_steps == 0:
|
if args.eval_accumulation_steps is not None and self.accelerator.sync_gradients:
|
||||||
if losses_host is not None:
|
if losses_host is not None:
|
||||||
losses = nested_numpify(losses_host)
|
losses = nested_numpify(losses_host)
|
||||||
all_losses = losses if all_losses is None else np.concatenate((all_losses, losses), axis=0)
|
all_losses = losses if all_losses is None else np.concatenate((all_losses, losses), axis=0)
|
||||||
|
Loading…
Reference in New Issue
Block a user