Deep learning 深度学习模式训练中学习速度的修正
下面是配置库以优化语言模型的代码Deep learning 深度学习模式训练中学习速度的修正,deep-learning,pytorch,huggingface-transformers,language-model,gpt-2,Deep Learning,Pytorch,Huggingface Transformers,Language Model,Gpt 2,下面是配置库以优化语言模型的代码 training_args = TrainingArguments( output_dir="./gpt2-language-model", #The output directory num_train_epochs=100, # number of training epochs per_device_train_batch_size=8, # batch size for training
training_args = TrainingArguments(
output_dir="./gpt2-language-model", #The output directory
num_train_epochs=100, # number of training epochs
per_device_train_batch_size=8, # batch size for training #32, 10
per_device_eval_batch_size=8, # batch size for evaluation #64, 10
save_steps=100, # after # steps model is saved
warmup_steps=500,# number of warmup steps for learning rate scheduler
prediction_loss_only=True,
metric_for_best_model = "eval_loss",
load_best_model_at_end = True,
evaluation_strategy="epoch",
learning_rate=0.00004, # learning rate
)
early_stop_callback = EarlyStoppingCallback(early_stopping_patience = 3)
trainer = Trainer(
model=gpt2_model,
args=training_args,
data_collator=data_collator,
train_dataset=train_dataset,
eval_dataset=test_dataset,
callbacks = [early_stop_callback],
)
的纪元数为100和学习率为0.00004,以及提前停止的耐心值配置为3
该模型运行了5/100个时期,并注意到损耗_值的差异可以忽略不计。最新的检查点保存为checkpoint latest
现在,我可以将学习率从0.00004
修改为0.01
,并从最新保存的检查点-检查点最新
恢复培训吗?这样做会有效率吗
或者要使用新的学习率
值进行培训,我是否应该从一开始就开始培训Pytorch提供了几种调整学习率的方法:torch.optim.lr\u scheduler。
检查文档的使用情况不,您不必重新开始培训。
改变学习率就像改变模型在损失函数决定的方向上迈出的一大步
您还可以将其视为转移学习,其中模型具有一些经验(无论多么少或不相关),并且权重处于状态,很可能比随机初始化的权重更好
事实上,在训练中改变学习速度被认为是深度学习中的一门艺术,如果你有很好的理由去做,你应该改变它
如果你或其他人想“复制”你的模型的结果,你可能想写下(为什么,什么等等)。