lonePatient / Bert-Multi-Label-Text-Classification

This repo contains a PyTorch implementation of a pretrained BERT model for multi-label text classification.
MIT License
878 stars 207 forks source link

A Problem in --do_data #49

Open CS18B opened 4 years ago

CS18B commented 4 years ago

When I do "python run_bert.py --do_data", I met this problem. My pytorch version is 1.5.0+cuda10.1

OSError: [Errno 22] Invalid argument: 'D:\\Desktop\\BERT+XLNET Multi-label\\pybert\\output\\log\\bert-2020-05-31-17:54:48.log' The complete error message is shown below, is that because the log file is missing?

(pytorch_gpu) D:\Desktop\BERT+XLNET Multi-label>python run_bert.py --do_data Traceback (most recent call last): File "run_bert.py", line 216, in <module> main() File "run_bert.py", line 192, in main init_logger(log_file=config['log_dir'] / f'{args.arch}-{time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime())}.log') File "D:\Desktop\BERT+XLNET Multi-label\pybert\common\tools.py", line 38, in init_logger file_handler = logging.FileHandler(log_file) File "D:\anaconda\anaconda1\envs\pytorch_gpu\lib\logging\__init__.py", line 1087, in __init__ StreamHandler.__init__(self, self._open()) File "D:\anaconda\anaconda1\envs\pytorch_gpu\lib\logging\__init__.py", line 1116, in _open return open(self.baseFilename, self.mode, encoding=self.encoding) OSError: [Errno 22] Invalid argument: 'D:\\Desktop\\BERT+XLNET Multi-label\\pybert\\output\\log\\bert-2020-05-31-17:54:48.log'

How to fix it? thx.

voidzyc commented 4 years ago

My way to solve this problem is modify ":" into "_" or any other character in run_bert.py, line 192 init_logger(log_file=config['log_dir'] / f'{args.arch}-{time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime())}.log') I think this problem is caused by ":" but I don't know why.

CS18B commented 4 years ago

My way to solve this problem is modify ":" into "_" or any other character in run_bert.py, line 192 init_logger(log_file=config['log_dir'] / f'{args.arch}-{time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime())}.log') I think this problem is caused by ":" but I don't know why.

It works! thank you so much!😀