зеркало из https://github.com/microsoft/DeBERTa.git
fix logger bug & update readme (#9)
This commit is contained in:
Родитель
c1a08e5644
Коммит
f97e77a3a4
|
@ -12,7 +12,7 @@ logging.basicConfig(format = '%(asctime)s|%(levelname)s|%(name)s| %(message)s',
|
|||
datefmt = '%m%d%Y %H:%M:%S',
|
||||
level = logging.INFO)
|
||||
logger=None
|
||||
def set_logger(name, file_log, rank=0, verbose=1):
|
||||
def set_logger(name, file_log=None, rank=0, verbose=1):
|
||||
global logger
|
||||
if not logger:
|
||||
logger = logging.getLogger(name)
|
||||
|
@ -25,11 +25,11 @@ def set_logger(name, file_log, rank=0, verbose=1):
|
|||
formatter = logging.Formatter(f'%(asctime)s|%(levelname)s|%(name)s|{rank:02}| %(message)s', datefmt='%m/%d/%Y %H:%M:%S')
|
||||
else:
|
||||
formatter = logging.Formatter(f'%(asctime)s|%(levelname)s|%(name)s| %(message)s', datefmt='%m/%d/%Y %H:%M:%S')
|
||||
|
||||
fh = logging.FileHandler(file_log)
|
||||
fh.setLevel(logging.DEBUG)
|
||||
fh.setFormatter(formatter)
|
||||
logger.addHandler(fh)
|
||||
if file_log:
|
||||
fh = logging.FileHandler(file_log)
|
||||
fh.setLevel(logging.DEBUG)
|
||||
fh.setFormatter(formatter)
|
||||
logger.addHandler(fh)
|
||||
|
||||
# Stdout
|
||||
# create console handler with a higher log level
|
||||
|
@ -46,7 +46,7 @@ def set_logger(name, file_log, rank=0, verbose=1):
|
|||
logger.propagate=False
|
||||
return logger
|
||||
|
||||
def get_logger(name='logging', file_log='/tmp/log.txt', rank=0, verbose=1):
|
||||
def get_logger(name='logging', file_log=None, rank=0, verbose=1):
|
||||
global logger
|
||||
if not logger:
|
||||
logger = set_logger(name, file_log, rank, verbose)
|
||||
|
|
|
@ -84,7 +84,7 @@ tokenizer = deberta.GPT2Tokenizer()
|
|||
max_seq_len = 512
|
||||
tokens = tokenizer.tokenize('Examples input text of DeBERTa')
|
||||
# Truncate long sequence
|
||||
tokens = tokens[:max_seq_len]
|
||||
tokens = tokens[:max_seq_len -2]
|
||||
# Add special tokens to the `tokens`
|
||||
tokens = ['[CLS]'] + tokens + ['[SEP]']
|
||||
input_ids = tokenizer.convert_tokens_to_ids(tokens)
|
||||
|
|
Загрузка…
Ссылка в новой задаче