sktime / pytorch-forecasting

Time series forecasting with PyTorch
https://pytorch-forecasting.readthedocs.io/
MIT License
3.87k stars 614 forks source link

A bug when importing pytorch_forecasting #1479

Open kkckk1110 opened 9 months ago

kkckk1110 commented 9 months ago

Expected behavior

I executed code from pytorch_forecasting.models.temporal_fusion_transformer.tuning import optimize_hyperparameters but have the following error:

TypeError Traceback (most recent call last) Cell In[10], line 18 16 from pytorch_forecasting.data import GroupNormalizer 17 from pytorch_forecasting.metrics import MAE, MAPE,SMAPE, MAPE,PoissonLoss, QuantileLoss ---> 18 from pytorch_forecasting.models.temporal_fusion_transformer.tuning import optimize_hyperparameters 19 from pytorch_forecasting.data.examples import get_stallion_data 20 import datetime

File D:\Anaconda\envs\torch\lib\site-packages\pytorch_forecasting\models\temporal_fusion_transformer\tuning.py:29 25 optuna_logger = logging.getLogger("optuna") 28 # need to inherit from callback for this to work ---> 29 class PyTorchLightningPruningCallbackAdjusted(pl.Callback, PyTorchLightningPruningCallback): 30 pass 33 def optimize_hyperparameters( 34 train_dataloaders: DataLoader, 35 val_dataloaders: DataLoader, (...) 52 **kwargs, 53 ) -> optuna.Study:

TypeError: Cannot create a consistent method resolution order (MRO) for bases Callback, PyTorchLightningPruningCallback del should be also included.

ruuttt commented 9 months ago

For me it worked to downgrade to optuna version 3.4 and pytorch 2.0.1 pip install torch==2.0.1 pytorch-lightning==2.0.2 pytorch_forecasting==1.0.0 torchaudio==2.0.2 torchdata==0.6.1 torchtext==0.15.2 torchvision==0.15.2 optuna==3.4

flight505 commented 7 months ago

same issue, optuna version 3.5, pytorch 2.2 and pytorch_forecasting==1.0.0 hope to see it resolved

Superzero31 commented 6 months ago

same issue with: optuna==3.5 pytorch-lightning==2.2.1 pytorch_forecasting==1.0.0

tty666 commented 6 months ago

I agree I have the same issue here with :

torch 2.2.1
optuna 3.6.0
pytorch-lightning 2.2.1
pytorch-forecasting 1.0.0
XinyuWuu commented 5 months ago

also see https://github.com/jdb78/pytorch-forecasting/issues/1468