timeseriesAI / tsai

Time series Timeseries Deep Learning Machine Learning Python Pytorch fastai | State-of-the-art Deep Learning library for Time Series and Sequences in Pytorch / fastai
https://timeseriesai.github.io/tsai/
Apache License 2.0
4.92k stars 622 forks source link

MLP (and other non-Plus) models are broken: custom_head in kwargs, mismatched tensors #841

Open E-Penguin opened 9 months ago

E-Penguin commented 9 months ago

Quite a few models, including MLP but not only, complain of unexpected custom_head in kwargs. I've worked-around it by adding custom_head=None to the affected constructors, and just ignore the parameter.

With the custom_head=None work-around the model runs, however the default loss functions complain of mismatched tensors: RuntimeError: The size of tensor a (64) must match the size of tensor b (640) at non-singleton dimension 0

I'm not doing anything particularly strange, and the same code works when using the "Plus" models.

arch='MLP'
arch_config={}

reg = TSForecaster(X_train, 
                          y_train, 
                          path='models', 
                          arch=arch,
                          arch_config=arch_config,
                          tfms=tfms, 
                          batch_tfms=batch_tfms, 
                          batch_size=batch_size,
                          patch_len=batch_size,
                          metrics=rmse,
                          splits=splits,
                          seed = seed,
                          verbose=True)

        self.reg.fit_one_cycle(self.config.epochs, 3e-4, cbs=cbs)