深度学习踩坑记录(持续更新)

时间:2024-03-13 09:05:26

运行时未指定 output_dir 参数

解决办法1:使用命令行运行程序 python main.py --output_dir ./output

解决办法2:若使用pycharm运行,可右键选择 Modify Run Configuration,设置运行脚本参数--output_dir ./output

解决办法3:继承TrainingArguments重新初始化output_dir,同时也可以初始化其他超参数

from transformers import TrainingArguments

@dataclass
class MyTrainingArguments(TrainingArguments):
    max_steps: int = field(default=5000)
    save_steps: int = field(default=100)
    learning_rate: float = field(default=5e-5)
    logging_steps: int = field(default=10)
    output_dir: str = field(default='output')
    per_device_train_batch_size: int = field(default=1)
    gradient_accumulation_steps: int = field(default=8)
    do_train: bool = field(default=True)

training_args = HfArgumentParser(MyTrainingArguments).parse_args_into_dataclasses()[0]