"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "83d1fbcff608f84a27234e20d6531b4404dc059e"
Unverified Commit 76681015 authored by LZR's avatar LZR Committed by GitHub
Browse files

round epoch only in console (#30237)

parent fe2d20d2
...@@ -3048,7 +3048,7 @@ class Trainer: ...@@ -3048,7 +3048,7 @@ class Trainer:
The values to log. The values to log.
""" """
if self.state.epoch is not None: if self.state.epoch is not None:
logs["epoch"] = round(self.state.epoch, 2) logs["epoch"] = self.state.epoch
if self.args.include_num_input_tokens_seen: if self.args.include_num_input_tokens_seen:
logs["num_input_tokens_seen"] = self.state.num_input_tokens_seen logs["num_input_tokens_seen"] = self.state.num_input_tokens_seen
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
""" """
Callbacks to use with the Trainer class and customize the training loop. Callbacks to use with the Trainer class and customize the training loop.
""" """
import copy
import dataclasses import dataclasses
import json import json
from dataclasses import dataclass from dataclasses import dataclass
...@@ -520,7 +521,12 @@ class ProgressCallback(TrainerCallback): ...@@ -520,7 +521,12 @@ class ProgressCallback(TrainerCallback):
def on_log(self, args, state, control, logs=None, **kwargs): def on_log(self, args, state, control, logs=None, **kwargs):
if state.is_world_process_zero and self.training_bar is not None: if state.is_world_process_zero and self.training_bar is not None:
# avoid modifying the logs object as it is shared between callbacks
logs = copy.deepcopy(logs)
_ = logs.pop("total_flos", None) _ = logs.pop("total_flos", None)
# round numbers so that it looks better in console
if "epoch" in logs:
logs["epoch"] = round(logs["epoch"], 2)
self.training_bar.write(str(logs)) self.training_bar.write(str(logs))
def on_train_end(self, args, state, control, **kwargs): def on_train_end(self, args, state, control, **kwargs):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment