英文:
`model` must be a `LightningModule` or `torch._dynamo.OptimizedModule`, got `TemporalFusionTransformer`
问题
我尝试使用pytorch_forecasting模块中的Temporal Fusion Transformer,但在trainer.fit方法中出现错误:'model'必须是'LightningModule'或'torch._dynamo.OptimizedModule',得到了'TemporalFusionTransformer'。我只是复制了'towardsdatascience'上的这篇论文。参考链接:https://towardsdatascience.com/temporal-fusion-transformer-time-series-forecasting-with-deep-learning-complete-tutorial-d32c1e51cd91#:~:text=T%20emporal%20F%20usion%20T,dynamics%20of%20multiple%20time%20sequences.
英文:
im trying to temporal fusion transformer from pytorch_forecasting module but im getting the error in trainer.fit method:model
must be a LightningModule
or torch._dynamo.OptimizedModule
, got TemporalFusionTransformer
.I'm just replicating this paper from 'towardsdatascience'.reference:https://towardsdatascience.com/temporal-fusion-transformer-time-series-forecasting-with-deep-learning-complete-tutorial-d32c1e51cd91#:~:text=T%20emporal%20F%20usion%20T,dynamics%20of%20multiple%20time%20sequences.
答案1
得分: 5
pytorch-forecasting
的要求已更新,pytorch lightning不再导入为lightning.pytorch
,而是pytorch_lightning
。
在pytorch-forecasting
的basemodel.py
中进行此更改解决了我的问题。
英文:
There has been an update to pytorch-forecasting
requirements and pytorch lightning no longer imports as lightning.pytorch
, but pytorch_lightning
.
Changing this in pytorch-forecasting
basemodel.py
solved the issue for me.
答案2
得分: 2
Soffies'回答基本上是正确的。根本原因是import/from lightning.pytorch与import/from pytorch_lightning不兼容。
在pytorch_forecasting中,作者广泛使用import lightning.pytorch。
因此,你只需要在你的代码中将'pytorch_lightning'替换为'lightning.pytorch'。
另外,在更新到torch2后,我遇到了这个问题。
英文:
Soffies' answer is basically correct. The fundamental reason is that import/from lightning.pytorch is incompatible with import/from pytorch_lightning.
In pytorch_forecasting, the author uses import lightning.pytorch extensively.
Therefore, all you need to do is to replace 'pytorch_lightning' with 'lightning.pytorch' in the your code.
Additionally, I encountered this issue after updating to torch2
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论