sktime / pytorch-forecasting

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

Stallion tutorial - AttributeError: 'str' object has no attribute '__name__' #354

Closed FedericoCampe8 closed 3 years ago

FedericoCampe8 commented 3 years ago

Expected behavior

Executing the code from the

Demand forecasting with the Temporal Fusion Transformer

tutorial (i.e., stallion example) should run fine.

Actual behavior

When fitting the network ([10])

# fit network
trainer.fit(
    tft,
    train_dataloader=train_dataloader,
    val_dataloaders=val_dataloader,
)

it throws an attribute error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-11-263e8be26564> in <module>
      1 # fit network
----> 2 trainer.fit(
      3     tft,
      4     train_dataloader=train_dataloader,
      5     val_dataloaders=val_dataloader,
...
lib/python3.8/site-packages/pytorch_lightning/core/saving.py in save_hparams_to_yaml(config_yaml, hparams)
    397     for k, v in hparams.items():
    398         try:
--> 399             yaml.dump(v)
    400         except TypeError:
    401             warn(f"Skipping '{k}' parameter because it is not possible to safely dump to YAML.")

lib/python3.8/site-packages/yaml/__init__.py in dump(data, stream, Dumper, **kwds)
    288     If stream is None, return the produced string instead.
    289     """
--> 290     return dump_all([data], stream, Dumper=Dumper, **kwds)
    291 
    292 def safe_dump_all(documents, stream=None, **kwds):
...
lib/python3.8/site-packages/yaml/representer.py in represent_object(self, data)
    329         if dictitems is not None:
    330             dictitems = dict(dictitems)
--> 331         if function.__name__ == '__newobj__':
    332             function = args[0]
    333             args = args[1:]

AttributeError: 'str' object has no attribute '__name__'

Code to reproduce the problem

Simply run the tutorial, no modifications.

jdb78 commented 3 years ago

Seems to be the new version of PyTorch lightning. Try for the moment with <1.2 (see #353).

FedericoCampe8 commented 3 years ago

Thanks, a previous version of PyTorch lightning solves the problem. The bug is in the 1.2.

123mitnik commented 3 years ago

yes! i can confirm - the issue is with the v.1.2 - the version of pytorch-lightning must be downgraded to 1.1.8 in order to work