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.
`model` must be a `LightningModule` or `torch._dynamo.OptimizedModule`, got `TemporalFusionTransformer`
4.1k Views Asked by Atharva Kumbhakarn At
3
There are 3 best solutions below
1
On
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
There has been an update to
pytorch-forecastingrequirements and pytorch lightning no longer imports aslightning.pytorch, butpytorch_lightning.Changing this in
pytorch-forecastingbasemodel.pysolved the issue for me.