tsai icon indicating copy to clipboard operation
tsai copied to clipboard

MultiInputNet - Create prediction on new test set

Open oguiza opened this issue 3 years ago • 1 comments

Discussed in https://github.com/timeseriesAI/tsai/discussions/345

Originally posted by shayp December 27, 2021 I'm having difficulties running prediction on a new test data set on MultiInputNet (TabModel and tsmodel). Iv'e Created dl for each input and combined it into MixedDataLoader.

` test_dl_tab = tab_dls.test_dl(X_features_test) test_dl_sig = ts_dls.new_dl(X=X_signal_test, y=y_test) mixed_test_dls = [test_dl_sig, test_dl_tab]

device = mixed_dls.train.device mixed_test_dl = MixedDataLoader(*mixed_test_dls, shuffle=False) test_probas, test_targets, test_preds = learn.get_preds(dl=mixed_test_dl, with_decoded=True,save_preds=None,save_targs=None,with_loss=False) `

But when running learn.get_preds I get TypeError: cross_entropy_loss(): argument 'target' (position 2) must be Tensor, not tuple

oguiza avatar Jan 18 '22 08:01 oguiza

I've been having an issue with this as well and can't really explain it. I was able to get predictions using the following:

test_df = pd.read_pickle('test_path')
X, y = df2xy(test_df.....)
X, y, splits = combine_split_data([X, X], [y, y])
dsets = TSDatasets(X, y, splits=splits, inplace=True)
dls = TSDataLoaders.from_dsets(dsets.train, dsets.valid)

Then create mixed loader (including tabular) the predict using:

preds, targets = learn.get_preds(dl=mixed_dls.valid, with_input=False)

Essentially treating the test files as valid files. Anything else I do I get an error in the loss function similar to yours, but the above works without a problem. It even fails if I try to create the split with 'get_splits'.

Just for reference my model consists of two InceptionTimePlus and 1x tabular. mixed_dls = get_mixed_dls(dls_1, dls_2, dls_tab) MultiModalNet = MultiInputNet(ITP_model_1, ITP_model_2, tab_model)

TKassis avatar Jan 26 '22 18:01 TKassis