tsai
tsai copied to clipboard
MultiInputNet not working on joint model composed of a TS model with a Tabular model
Following the example on the documentation (https://timeseriesai.github.io/tsai/models.MultiInputNet.html), I tried generating a MultiInputNet model, feeding it with a mixed dls:
tf = build_ts_model(TSTPlus, dls = dls_ts, ks = ks, n_layers = n_layers, d_model = d_model)
tab = build_tabular_model(TabModel, dls = dls_cat)
MultiModalNet = MultiInputNet(tf, tab)
mixed_dls = get_mixed_dls(dls_ts, dls_cat)
learn = Learner(mixed_dls, MultiModalNet, opt_func = SGD, loss_func = mse,
metrics=[mae, mse], cbs=cbs)
lr = learn.lr_find()[0]
The building works just fine, but when learning, it generates the following error:
File "C:\Users\user\AppData\Local\Temp/ipykernel_27804/3899531803.py", line 1, in <module>
lr = learn.lr_find()[0]
File "C:\Users\user\Anaconda3\lib\site-packages\fastai\callback\schedule.py", line 285, in lr_find
with self.no_logging(): self.fit(n_epoch, cbs=cb)
File "C:\Users\user\Anaconda3\lib\site-packages\fastai\learner.py", line 221, in fit
self._with_events(self._do_fit, 'fit', CancelFitException, self._end_cleanup)
File "C:\Users\user\Anaconda3\lib\site-packages\fastai\learner.py", line 163, in _with_events
try: self(f'before_{event_type}'); f()
File "C:\Users\user\Anaconda3\lib\site-packages\fastai\learner.py", line 212, in _do_fit
self._with_events(self._do_epoch, 'epoch', CancelEpochException)
File "C:\Users\user\Anaconda3\lib\site-packages\fastai\learner.py", line 163, in _with_events
try: self(f'before_{event_type}'); f()
File "C:\Users\user\Anaconda3\lib\site-packages\fastai\learner.py", line 206, in _do_epoch
self._do_epoch_train()
File "C:\Users\user\Anaconda3\lib\site-packages\fastai\learner.py", line 198, in _do_epoch_train
self._with_events(self.all_batches, 'train', CancelTrainException)
File "C:\Users\user\Anaconda3\lib\site-packages\fastai\learner.py", line 163, in _with_events
try: self(f'before_{event_type}'); f()
File "C:\Users\user\Anaconda3\lib\site-packages\fastai\learner.py", line 169, in all_batches
for o in enumerate(self.dl): self.one_batch(*o)
File "C:\Users\user\Anaconda3\lib\site-packages\tsai\learner.py", line 37, in one_batch
self._with_events(self._do_one_batch, 'batch', CancelBatchException)
File "C:\Users\user\Anaconda3\lib\site-packages\fastai\learner.py", line 163, in _with_events
try: self(f'before_{event_type}'); f()
File "C:\Users\user\Anaconda3\lib\site-packages\fastai\learner.py", line 175, in _do_one_batch
self.loss_grad = self.loss_func(self.pred, *self.yb)
File "C:\Users\user\Anaconda3\lib\site-packages\fastai\losses.py", line 32, in __call__
if self.floatify and targ.dtype!=torch.float16: targ = targ.float()
AttributeError: 'tuple' object has no attribute 'dtype'