philipperemy / n-beats

Keras/Pytorch implementation of N-BEATS: Neural basis expansion analysis for interpretable time series forecasting.
MIT License
854 stars 163 forks source link

TypeError: __init__() takes from 4 to 6 positional arguments but 7 were given #25

Closed mmortazavi closed 4 years ago

mmortazavi commented 4 years ago

I am getting started with n-beats; looks quite interesting, and simply trying to run the included Notebook (NBeats.ipynb) with the milk sample data, but I get the following error when optimization is about to start:

| N-Beats
| --  Stack Generic (#0) (share_weights_in_stack=False)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-59-151a00003124> in <module>
      7                 hidden_layer_units=128,
      8                 share_weights_in_stack=False,
----> 9                 device=device)
     10 optimiser = optim.Adam(net.parameters())

~\Anaconda3\envs\forecast\lib\site-packages\nbeats_pytorch\model.py in __init__(self, device, stack_types, nb_blocks_per_stack, forecast_length, backcast_length, thetas_dims, share_weights_in_stack, hidden_layer_units, nb_harmonics)
     34         print(f'| N-Beats')
     35         for stack_id in range(len(self.stack_types)):
---> 36             self.stacks.append(self.create_stack(stack_id))
     37         self.parameters = nn.ParameterList(self.parameters)
     38         self.to(self.device)

~\Anaconda3\envs\forecast\lib\site-packages\nbeats_pytorch\model.py in create_stack(self, stack_id)
     48             else:
     49                 block = block_init(self.hidden_layer_units, self.thetas_dim[stack_id],
---> 50                                    self.device, self.backcast_length, self.forecast_length, self.nb_harmonics)
     51                 self.parameters.extend(block.parameters())
     52             print(f'     | -- {block}')

TypeError: __init__() takes from 4 to 6 positional arguments but 7 were given

Here is what I have at the moment in Windows:

nbeats-pytorch 1.3.1 torch 1.4.0+cpu pandas 0.25.3 numpy 1.18.2 python 3.6.7

Something is changed in the base code that perhaps is not updated in the example?

philipperemy commented 4 years ago

@mmortazavi yep I probably haven't updated the notebook since last time. I'm going to update it.

philipperemy commented 4 years ago

@mmortazavi I fixed it. Try it again and let me know. It worked for me.

mmortazavi commented 4 years ago

Just to add for those facing same issue that the notebook is updated, but you need to pull the latest changes from git, as a few lines are code have changed, or manually apply the @philipperemy 's changes like I did, and thanks it works.

Priyatham10 commented 4 years ago

Just to add for those facing same issue that the notebook is updated, but you need to pull the latest changes from git, as a few lines are code have changed, or manually apply the @philipperemy 's changes like I did, and thanks it works.

I cloned the specific commit at this notebook update. But, still I am facing the same error. Can you please tell me what did you do when you said, you

manually applied @philipperemy 's changes

means in some detailed process for me to follow.. Thank you..

mmortazavi commented 4 years ago

@Priyatham10 I manually applied the changes taking from this commit, take the lastest notebook. It worked for me this way. I am not sure cloning directly from the repo doesn't work though.