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
5.07k stars 633 forks source link

how to preds when using the TS-to-ImageClassification model? #681

Closed jiangtaochen closed 12 months ago

jiangtaochen commented 1 year ago

I was following the tutorial to convert time-series as Images. and the training process is over ;but i have some problem when I using the model to preds the ublabeled test dataset ?what should I to input in the function learn.get_X_preds(X_test)?what is the typr of "X_test"? ndarray or TSImage?。 here is my code :+1: training:

batch_tfms =[TSNormalize(),TSToGADF()]
dls = TSDataLoaders.from_dsets(dsets.train,dsets.valid,bs = [64,128],batch_tfms = batch_tfms,num_workers=0)
model = create_model(xresnet18,dls=dls)
learn = Learner(dls, model,metrics=accuracy)  #
learn.fit_one_cycle(100, lr_max=2e-5)
learn.export(pkl_name)

inference:

learn = load_learner(model_name)
out= TSToGADF()(TSTensor(X_test),split_idx = 0)
test_probas1, test_targets1, test_preds1 = learn.get_X_preds(out)

when I input the TSImage ,some error occurs: image

but when I input array ,it works ,but the accuracy is very low,and all the inference results are all the same,it seems not the right way. so what is the typr of "X_test"? ndarray or TSImage?。

oguiza commented 1 year ago

Hi @jiangtaochen, The input to generate predictions is the same as the input to the dataloaders you used in training: numpy arrays. The learner stores the batch_transforms, so it knows what needs to be applied.

oguiza commented 12 months ago

Closed due to lack of response.