Morizeyao / GPT2-Chinese

Chinese version of GPT2 training code, using BERT tokenizer.
MIT License
7.48k stars 1.7k forks source link

fix: ensure that the entire directory path is created; refactor: don't use same variable name in the parent loop; #294

Open RealHurrison opened 7 months ago

RealHurrison commented 7 months ago

Using os.mkdir to create a directory can lead to an error if the parent directory does not exist. It's safer to use os.makedirs with the exist_ok=True parameter to ensure that the entire directory path is created if it does not exist. The original line uses os.mkdir which can fail if the directory's parent does not exist. Changing it to os.makedirs and adding the exist_ok=True parameter ensures that the directory is created along with any necessary parent directories, preventing potential runtime errors.

lishangru commented 7 months ago

thankyou