unit8co / darts

A python library for user-friendly forecasting and anomaly detection on time series.
https://unit8co.github.io/darts/
Apache License 2.0
7.91k stars 857 forks source link

[BUG] Torch Models fit: ValueError: __len__() should return >= 0 #276

Closed vl2376 closed 3 years ago

vl2376 commented 3 years ago

Describe the bug

I get the following error when trying to run a torch model (I have tried RNN, NBEATS):

  File "darts\models\torch_forecasting_model.py", line 292, in fit
    logger.info('Train dataset contains {} samples.'.format(len(train_dataset)))

ValueError: __len__() should return >= 0

To Reproduce

from darts.models import RNNModel, NBEATSModel

model = RNNModel(model = "RNN",
                  input_chunk_length = len(train),
                  output_chunk_length = len(test))

model.fit(series = train)

System (please complete the following information):

mustafaaydn commented 3 years ago

Hi, you are supplying the whole training series' length as the input_chunk_length here:

input_chunk_length = len(train),

and therefore there remains no target value to form the "labels" in the supervised setting for the RNN! The figure here i think will clarify things (the situation corresponds there as if you supplied input_chunk_length=14)

hrzn commented 3 years ago

Thanks for the answer @mustafaaydn, that's correct.