mirror of
https://gitee.com/fastnlp/fastNLP.git
synced 2024-12-05 05:38:31 +08:00
[update] docs for logger & dist_trainer
This commit is contained in:
parent
1d7d05716e
commit
03bee90521
@ -1,4 +1,20 @@
|
||||
"""undocumented"""
|
||||
"""
|
||||
Logger 是fastNLP中记录日志的模块,logger封装了logging模块的Logger,
|
||||
具体使用方式与直接使用logging.Logger相同,同时也新增一些简单好用的API
|
||||
使用方式:
|
||||
from fastNLP import logger
|
||||
#
|
||||
# logger 可以和 logging.Logger 一样使用
|
||||
logger.info('your msg')
|
||||
logger.error('your msg')
|
||||
|
||||
# logger 新增的API
|
||||
# 将日志输出到文件,以及输出的日志等级
|
||||
logger.add_file('/path/to/log', level='INFO')
|
||||
# 定义在命令行中的显示格式和日志等级
|
||||
logger.set_stdout('tqdm', level='WARN')
|
||||
|
||||
"""
|
||||
|
||||
__all__ = [
|
||||
'logger',
|
||||
@ -108,11 +124,11 @@ class FastNLPLogger(logging.getLoggerClass()):
|
||||
super().__init__(name)
|
||||
|
||||
def add_file(self, path='./log.txt', level='INFO'):
|
||||
"""add log output file and level"""
|
||||
"""add log output file and the output level"""
|
||||
_add_file_handler(self, path, level)
|
||||
|
||||
def set_stdout(self, stdout='tqdm', level='INFO'):
|
||||
"""set stdout format and level"""
|
||||
"""set stdout format and the output level"""
|
||||
_set_stdout_handler(self, stdout, level)
|
||||
|
||||
|
||||
@ -152,4 +168,4 @@ def _get_logger(name=None, level='INFO'):
|
||||
return logger
|
||||
|
||||
|
||||
logger = _init_logger(path=None)
|
||||
logger = _init_logger(path=None, level=1) # make the logger the lowest level
|
||||
|
@ -1,5 +1,8 @@
|
||||
"""undocumented
|
||||
正在开发中的分布式训练代码
|
||||
"""
|
||||
分布式 Trainer
|
||||
使用步骤
|
||||
1. 在代码中调用 DistTrainer,类似 Trainer,传入模型和数据等等参数
|
||||
2. 在命令行中,将 python your_script.py 替换为 python -m torch.distributed.launch --nproc_per_node=N your_script.py
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
|
Loading…
Reference in New Issue
Block a user