File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6161 "If the trainer hangs for longer than this interval, "
6262 "the trainer will crash to prevent indefinite hanging." ,
6363)
64+ flags .DEFINE_integer (
65+ "trainer_log_every_n_steps" ,
66+ None ,
67+ "Logging frequency for the loss value during training. "
68+ "If None, defaults to every 100 steps." ,
69+ )
6470flags .DEFINE_enum (
6571 "device_monitor" ,
6672 "none" ,
@@ -120,6 +126,8 @@ def get_trainer_config(
120126 trainer_config .crash_on_hang_timeout_seconds = (
121127 flag_values .trainer_crash_on_hang_timeout_seconds
122128 )
129+ if trainer_config .log_every_n_steps is None :
130+ trainer_config .log_every_n_steps = flag_values .trainer_log_every_n_steps
123131 for eval_cfg in trainer_config .evalers .values ():
124132 eval_cfg .trace_at_iters = [int (el ) for el in flag_values .eval_trace_at_iters ]
125133 if flag_values .device_monitor == "tpu" :
Original file line number Diff line number Diff line change @@ -217,6 +217,10 @@ class Config(Module.Config):
217217 # Defaults to None which is interpreted as True.
218218 cache_compiled_train_step : Optional [bool ] = None
219219
220+ # Log the loss value every n steps. Defaults to None which is interpreted as every
221+ # 100 steps.
222+ log_every_n_steps : Optional [int ] = None
223+
220224 def __init__ (
221225 self ,
222226 cfg : Config ,
@@ -1111,7 +1115,8 @@ def _run_step(
11111115 # Run the compiled function.
11121116 self ._trainer_state , outputs = compiled_train_step_fn (self .trainer_state , input_batch )
11131117
1114- if self .step % 100 == 0 or 0 <= self .step <= 5 :
1118+ n = self ._config .log_every_n_steps or 100
1119+ if self .step % n == 0 or 0 <= self .step <= 5 :
11151120 self ._step_log (
11161121 "loss=%s aux=%s" ,
11171122 outputs ["loss" ],
You can’t perform that action at this time.
0 commit comments