gpt4 book ai didi

python - huggingface 变形金刚 longformer 优化器警告 AdamW

转载 作者:行者123 更新时间:2023-12-05 04:35:05 24 4
gpt4 key购买 nike

当我尝试运行此 page 中的代码时,我收到以下警告.

/usr/local/lib/python3.7/dist-packages/transformers/optimization.py:309: FutureWarning: This implementation of AdamW is deprecated and will be removed in a future version. Use thePyTorch implementation torch.optim.AdamW instead, or set `no_deprecation_warning=True` to disable this warning
FutureWarning,

我非常困惑,因为代码似乎根本没有设置优化器。最有可能设置优化器的地方可能在下面,但我不知道如何更改优化器

# define the training arguments
training_args = TrainingArguments(
output_dir = '/media/data_files/github/website_tutorials/results',
num_train_epochs = 5,
per_device_train_batch_size = 8,
gradient_accumulation_steps = 8,
per_device_eval_batch_size= 16,
evaluation_strategy = "epoch",
disable_tqdm = False,
load_best_model_at_end=True,
warmup_steps=200,
weight_decay=0.01,
logging_steps = 4,
fp16 = True,
logging_dir='/media/data_files/github/website_tutorials/logs',
dataloader_num_workers = 0,
run_name = 'longformer-classification-updated-rtx3090_paper_replication_2_warm'
)

# instantiate the trainer class and check for available devices
trainer = Trainer(
model=model,
args=training_args,
compute_metrics=compute_metrics,
train_dataset=train_data,
eval_dataset=test_data
)
device = 'cuda' if torch.cuda.is_available() else 'cpu'
device

我使用相同的代码尝试了另一个转换器,例如 distilbert-base-uncased,但它似乎在没有任何警告的情况下运行。

  1. 此警告是否更针对 longformer
  2. 我应该如何更改优化器?

最佳答案

import torch_optimizer as optim

optim.AdamW(params, opt.learning_rate, (opt.optim_alpha, opt.optim_beta), opt.optim_epsilon, weight_decay=opt.weight_decay)

可以这样使用。

关于python - huggingface 变形金刚 longformer 优化器警告 AdamW,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71113363/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com