Skip to content

Commit

Permalink
Remove truncate (#8375)
Browse files Browse the repository at this point in the history
Remove truncate
  • Loading branch information
KB-Ding authored May 7, 2024
1 parent 89daaa3 commit 27d0e60
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions paddlenlp/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2721,11 +2721,15 @@ def evaluation_loop(
# Number of losses has been rounded to a multiple of batch_size and in a distributed training, the number of
# samplers has been rounded to a multiple of batch_size, so we truncate.
if all_losses is not None:
all_losses = all_losses[:num_samples]
all_losses = all_losses[: num_samples * int(self.args.world_size / self.args.dataset_world_size)]
if all_preds is not None:
all_preds = nested_truncate(all_preds, num_samples)
all_preds = nested_truncate(
all_preds, num_samples * int(self.args.world_size / self.args.dataset_world_size)
)
if all_labels is not None:
all_labels = nested_truncate(all_labels, num_samples)
all_labels = nested_truncate(
all_labels, num_samples * int(self.args.world_size / self.args.dataset_world_size)
)

model.train()

Expand Down

0 comments on commit 27d0e60

Please sign in to comment.