philipperemy / n-beats

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

NBeats.ipynb not running #34

Closed paularindam closed 3 years ago

paularindam commented 4 years ago

I am getting error when running this example when running NBeats.ipynb while running the following command. If I remove stack_types or set it as ('trend','seasonality') it works fine. But it gives error with GENERIC_BLOCK

net = NBeatsNet(device=device, stack_types=(NBeatsNet.GENERIC_BLOCK, NBeatsNet.GENERIC_BLOCK), forecast_length=forecast_length, backcast_length=backcast_length, hidden_layer_units=128, share_weights_in_stack=False, )

Error Statement

TypeError Traceback (most recent call last)

in () 4 backcast_length=backcast_length, 5 hidden_layer_units=128, ----> 6 share_weights_in_stack=False, 7 ) ~/anaconda3/envs/pytorch_p36/lib/python3.6/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/pytorch_p36/lib/python3.6/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
dan-r95 commented 4 years ago

this worked for me

pnmartinez commented 3 years ago

As of Jan 18th 2021, the pip libraries are broken and give TypeErrors when building NbeatsNet.GENERIC_BLOCKS

WORKAROUND: uninstall the libraries from pip (pip uninstall nbeats-keras or pip uninstall nbeats-torch), and copy-paste the nbeats_pytorch folder in the repo on the directory where your code is (as this bug does not exist in the GitHub version).

philipperemy commented 3 years ago

I updated the code and pushed the new versions on pip so it should work properly now.

(I pushed the nbeats 1.3.3 version that should solve this).

pip install nbeats-pytorch --upgrade
pip install nbeats-keras --upgrade