sktime / pytorch-forecasting

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

Missing model.summarize("full") method #1119

Open FTWH opened 2 years ago

FTWH commented 2 years ago

Expected behavior

I executed code model.summarize("full") from https://pytorch-forecasting.readthedocs.io/en/stable/tutorials/building.html, in order to follow the tutorial and expected to get results as shown in the doc.

Actual behavior

However, result was `--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Input In [53], in <cell line: 81>() 72 return super().from_dataset(dataset, **new_kwargs) 75 model = FullyConnectedMultiTargetModel.from_dataset( 76 multi_target_dataset, 77 hidden_size=10, 78 n_hidden_layers=2, 79 loss=MultiLoss(metrics=[MAE(), SMAPE()], weights=[2.0, 1.0]), 80 ) ---> 81 model.summarize("full") 82 model.hparams

File ~/anaconda3/envs/faas-scaler/lib/python3.8/site-packages/torch/nn/modules/module.py:1207, in Module.getattr(self, name) 1205 if name in modules: 1206 return modules[name] -> 1207 raise AttributeError("'{}' object has no attribute '{}'".format( 1208 type(self).name, name))

AttributeError: 'FullyConnectedMultiTargetModel' object has no attribute 'summarize'` I think the basemodel class method has no summarize is the reason.

Code to reproduce the problem

Follow the code in the official website.

Paste the command(s) you ran and the output. Including a link to a colab notebook will speed up issue resolution. If there was a crash, please include the traceback here. The code used to initialize the TimeSeriesDataSet and model should be also included.

zhengkd95 commented 2 years ago

Guess this is caused by the change of built-in function from LightningModule. An alternative way of summarizing the model is:

from pytorch_lightning.utilities.model_summary import summarize
summarize(model,max_depth=-1)