Closed GitGabbo closed 1 year ago
Hi @GitGabbo,
All you need to do to create an output with any dimension is to prepare a y with the desired dimension and choose any of the models ending with "Plus". tsai
will prepare the model to automatically generate the required output shape.
For example:
X = random_rand(229, 18, 164)
y = random_randint(0, 4, size=(229, 5)) # 4 classes
splits = TSSplitter(show_plot=False)(y)
print(X.shape, y.shape)
tfms = [None, TSClassification()]
batch_tfms = TSStandardize()
dls = get_ts_dls(X, y, splits=splits, tfms=tfms, batch_tfms=batch_tfms)
learn = ts_learner(dls, 'InceptionTimePlus', metrics=accuracy, cbs=[ShowGraph()])
xb, yb = dls.train.one_batch()
print(learn.model.to(xb.device)(xb).shape)
# torch.Size([64, 5, 4])
So you can train it using:
learn.fit_one_cycle(1, 1e-3)
It was exactly what I was looking for. Thank you very much @oguiza for your quick response and for your fantastic work!
Closed based on previous response.
I'd like to predict, starting from the same input, an array of outputs. I have the 3d numpy array X of shape (229, 18, 164) and I'd want to pass to the TSDatasets also a Y that has a shape of (229, 5), e.g.
array([[4, 4, 5, 5, 5], [4, 4, 5, 5, 5], [4, 4, 5, 5, 5], ...])
.The question is, is it possible somehow? What tfms/tls should I use?