checkpoints.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:triple-gan 作者: zhenxuan00 项目源码 文件源码
def build_log_file(cfg):
    FORMAT="%(asctime)s;%(levelname)s|%(message)s"
    DATEF="%H-%M-%S"
    logging.basicConfig(formatter=FORMAT, level=logging.DEBUG)
    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)

    fh = logging.FileHandler(filename=os.path.join(cfg['outfolder'], 'logfile'+time.strftime("%m-%d")+'.log'))
    fh.setLevel(logging.DEBUG)
    formatter = logging.Formatter("%(asctime)s;%(levelname)s|%(message)s", "%H:%M:%S")
    fh.setFormatter(formatter)
    logger.addHandler(fh)

    LEVEL_STYLES = dict(
        debug=dict(color='magenta'),
        info=dict(color='green'),
        verbose=dict(),
        warning=dict(color='blue'),
        error=dict(color='yellow'),
        critical=dict(color='red',bold=True))
    coloredlogs.install(level=logging.DEBUG, fmt=FORMAT, datefmt=DATEF, level_styles=LEVEL_STYLES)


    args_dict = cfg
    sorted_args = sorted(args_dict.items(), key=operator.itemgetter(0))
    logging.info('######################################################')
    logging.info('# --Configurable Parameters In this Model--')
    for name, val in sorted_args:
        logging.info("# " + name + ":\t" + str(get_list_name(val)))
    logging.info('######################################################')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号