utils.log_helper¶
log_helper¶
Please Reference ding/ding/utils/log_helper.py for usage.
build_logger¶
- Overview:
Build text logger and tensorboard logger.
- Arguments:
path (
str): Logger(Textlogger&SummaryWriter)’s saved dirname (
str): The logger file nameneed_tb (
bool): WhetherSummaryWriterinstance would be created and returnedneed_text (
bool): WhetherloggingLoggerinstance would be created and returnedtext_level (
int`orstr): Logging level oflogging.Logger, default set tologging.INFO
- Returns:
logger (
Optional[logging.Logger]): Logger that displays terminal outputtb_logger (
Optional['SummaryWriter']): Saves output to tfboard, only return whenneed_tb.
LoggerFactory¶
- ding.utils.log_helper.LoggerFactory.create_logger(path: str, name: str = 'default', level: Union[int, str] = 20) → logging.Logger¶
- Overview:
Create logger using logging
- Arguments:
name (
str): Logger’s namepath (
str): Logger’s save dirlevel (
intorstr): Used to set the level. Reference:Logger.setLevelmethod.
- Returns:
(
logging.Logger): new logging logger
- ding.utils.log_helper.LoggerFactory.get_tabulate_vars(variables: Dict[str, Any]) → str¶
- Overview:
Get the text description in tabular form of all vars
- Arguments:
variables (
List[str]): Names of the vars to query.
- Returns:
string (
str): Text description in tabular form of all vars
DistributionTimeImage¶
- Overview:
DistributionTimeImagecan be used to store images accorrding totime_steps, for data with 3 dims``(time, category, value)``- Interface:
__init__,add_one_time_step,get_image
- ding.utils.log_helper.DistributionTimeImage.__init__(self, maxlen: int = 600, val_range: Optional[dict] = None)¶
- Overview:
Init the
DistributionTimeImageclass- Arguments:
maxlen (
int): The max length of data inputsval_range (
dictorNone): Dict withval_range['min']andval_range['max'].
- ding.utils.log_helper.DistributionTimeImage.add_one_time_step(self, data: numpy.ndarray) → None¶
- Overview:
Step one timestep in
DistributionTimeImageand add the data to distribution image- Arguments:
data (
np.ndarray): The data input
- ding.utils.log_helper.DistributionTimeImage.get_image(self) → numpy.ndarray¶
- Overview:
Return the distribution image
- Returns:
img (
np.ndarray): The calculated distribution image
pretty_print¶
- Overview:
Print a dict
resultin a pretty way- Arguments:
result (
dict): The result to printdirect_print (
bool): Whether to print directly
- Returns:
string (
str): The pretty-printed result in str format