gpt4 book ai didi

python - pytorch 闪电 "got an unexpected keyword argument ' weights_summary'"

转载 作者:行者123 更新时间:2023-12-05 08:03:07 26 4
gpt4 key购买 nike

尝试在 anaconda spyder 5.1.5 中学习 Google“temporal fusion transformer”算法时,我遇到了一个错误。伙计们,解决这个错误对我来说非常重要。应该有人说些什么。我会很高兴。我在下面的链接中使用的示例;

https://pytorch-forecasting.readthedocs.io/en/latest/tutorials/stallion.html

例如,当我开始运行下面提到的代码时,我得到了错误

study = optimize_hyperparameters(
train_dataloader,
val_dataloader,
model_path="optuna_test",
n_trials=200,
max_epochs=50,
gradient_clip_val_range=(0.01, 1.0),
hidden_size_range=(8, 128),
hidden_continuous_size_range=(8, 128),
attention_head_size_range=(1, 4),
learning_rate_range=(0.001, 0.1),
dropout_range=(0.1, 0.3),
trainer_kwargs=dict(limit_train_batches=30),
reduce_on_plateau_patience=4,
use_learning_rate_finder=False # use Optuna to find ideal learning rate or use in-built learning rate finder
)

下面是错误

A new study created in memory with name: no-name-fe7e21ce-3034-4679-b60a-ee4d5c9a4db5
[W 2022-10-21 19:36:49,382] Trial 0 failed because of the following error: TypeError("__init__() got an unexpected keyword argument 'weights_summary'")
Traceback (most recent call last):
File "C:\Users\omer\anaconda3\lib\site-packages\optuna\study\_optimize.py", line 196, in _run_trial
value_or_values = func(trial)
File "C:\Users\omer\anaconda3\lib\site-packages\pytorch_forecasting\models\temporal_fusion_transformer\tuning.py", line 150, in objective
trainer = pl.Trainer(
File "C:\Users\omer\anaconda3\lib\site-packages\pytorch_lightning\utilities\argparse.py", line 345, in insert_env_defaults
return fn(self, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'weights_summary'
Traceback (most recent call last):

Input In [3] in <cell line: 1>
study = optimize_hyperparameters(

File ~\anaconda3\lib\site-packages\pytorch_forecasting\models\temporal_fusion_transformer\tuning.py:217 in optimize_hyperparameters
study.optimize(objective, n_trials=n_trials, timeout=timeout)

File ~\anaconda3\lib\site-packages\optuna\study\study.py:419 in optimize
_optimize(

File ~\anaconda3\lib\site-packages\optuna\study\_optimize.py:66 in _optimize
_optimize_sequential(

File ~\anaconda3\lib\site-packages\optuna\study\_optimize.py:160 in _optimize_sequential
frozen_trial = _run_trial(study, func, catch)

File ~\anaconda3\lib\site-packages\optuna\study\_optimize.py:234 in _run_trial
raise func_err

File ~\anaconda3\lib\site-packages\optuna\study\_optimize.py:196 in _run_trial
value_or_values = func(trial)

File ~\anaconda3\lib\site-packages\pytorch_forecasting\models\temporal_fusion_transformer\tuning.py:150 in objective
trainer = pl.Trainer(

File ~\anaconda3\lib\site-packages\pytorch_lightning\utilities\argparse.py:345 in insert_env_defaults
return fn(self, **kwargs)

TypeError: __init__() got an unexpected keyword argument 'weights_summary'

代码有什么问题?请问有人可以帮助我吗?

最佳答案

所以,我有和你一样的笨蛋。

我建议您在代码中找到“weights_suammry”变量

我使用 .yaml 文件并使用 hydra 自动放置 pytorch_lightning.Trainer 的参数也使用 strategy=DDPStrategy(find~)

我刚刚意识到 .yaml 文件中有 weights_summary,

结构是

trainer:
_target_: ~~
~~:
weights_summary : "top"

然后我删除了它上面的 weights_summary,问题就解决了

关于python - pytorch 闪电 "got an unexpected keyword argument ' weights_summary'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74157157/

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