-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Refactor] Update analysis tools and documentations. (#1359)
* [Refactor] Update analysis tools and documentations. * Update migration.md and add unit test. * Fix print_config.py
- Loading branch information
Showing
13 changed files
with
285 additions
and
142 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
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
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
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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
from .analyze import load_json_log | ||
from .collect_env import collect_env | ||
from .progress import track_on_main_process | ||
from .setup_env import register_all_modules | ||
|
||
__all__ = ['collect_env', 'register_all_modules', 'track_on_main_process'] | ||
__all__ = [ | ||
'collect_env', 'register_all_modules', 'track_on_main_process', | ||
'load_json_log' | ||
] |
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,43 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
import json | ||
|
||
|
||
def load_json_log(json_log): | ||
"""load and convert json_logs to log_dicts. | ||
Args: | ||
json_log (str): The path of the json log file. | ||
Returns: | ||
dict: The result dict contains two items, "train" and "val", for | ||
the training log and validate log. | ||
Example: | ||
An example output: | ||
.. code-block:: python | ||
{ | ||
'train': [ | ||
{"lr": 0.1, "time": 0.02, "epoch": 1, "step": 100}, | ||
{"lr": 0.1, "time": 0.02, "epoch": 1, "step": 200}, | ||
{"lr": 0.1, "time": 0.02, "epoch": 1, "step": 300}, | ||
... | ||
] | ||
'val': [ | ||
{"accuracy/top1": 32.1, "step": 1}, | ||
{"accuracy/top1": 50.2, "step": 2}, | ||
{"accuracy/top1": 60.3, "step": 2}, | ||
... | ||
] | ||
} | ||
""" | ||
log_dict = dict(train=[], val=[]) | ||
with open(json_log, 'r') as log_file: | ||
for line in log_file: | ||
log = json.loads(line.strip()) | ||
# A hack trick to determine whether the line is training log. | ||
mode = 'train' if 'lr' in log else 'val' | ||
log_dict[mode].append(log) | ||
|
||
return log_dict |
Oops, something went wrong.