-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jinzhe Zeng <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
13a8adf
commit e826260
Showing
4 changed files
with
131 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
from typing import ( | ||
Dict, | ||
Optional, | ||
) | ||
|
||
|
||
def format_training_message( | ||
batch: int, | ||
wall_time: float, | ||
): | ||
"""Format a training message.""" | ||
return f"batch {batch:7d}: " f"total wall time = {wall_time:.2f} s" | ||
|
||
|
||
def format_training_message_per_task( | ||
batch: int, | ||
task_name: str, | ||
rmse: Dict[str, float], | ||
learning_rate: Optional[float], | ||
): | ||
if task_name: | ||
task_name += ": " | ||
if learning_rate is None: | ||
lr = "" | ||
else: | ||
lr = f", lr = {learning_rate:8.2e}" | ||
# sort rmse | ||
rmse = dict(sorted(rmse.items())) | ||
return ( | ||
f"batch {batch:7d}: {task_name}" | ||
f"{', '.join([f'{kk} = {vv:8.2e}' for kk, vv in rmse.items()])}" | ||
f"{lr}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters