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.21k stars 651 forks source link

TSClassification - TypeError: __init__() got an unexpected keyword argument 'custom_head' #661

Closed ninoslavc closed 1 year ago

ninoslavc commented 1 year ago

I have the following code in time series multivariate classification problem:

...
from tsai.models.MINIROCKETPlus_Pytorch import * 
from tsai.models.utils import *

X.shape #(2783, 10, 20000)

mrf = MiniRocketFeaturesPlus(X.shape[1], X.shape[2]).to(default_device(),dtype=torch.float32)
mrf.fit(X_train.astype(np.float32), chunksize = 64) #time = 5s

X_feat = get_minirocket_features(X.astype(np.float32), mrf, chunksize = 16, to_np = True) #time = 4 min
X_feat.shape #(2783, 9996, 1)

# Using tsai/fastai, create DataLoaders for the features in X_feat.
tfms = [None, TSClassification()]
batch_tfms = TSStandardize(by_sample=True)
dls = get_ts_dls(X_feat, y, splits=splits, tfms=tfms, batch_tfms=batch_tfms)

# model is a linear classifier Head
model = build_ts_model(MiniRocketHead, dls=dls) # <== this line raises the error: TypeError: __init__() got an unexpected keyword argument 'custom_head'
model.head
...
os              : Windows-10-10.0.19044-SP0
python          : 3.9.13
tsai            : 0.3.4
fastai          : 2.7.10
fastcore        : 1.5.27
sktime          : 0.15.0
sklearn         : 1.1.3
torch           : 1.13.1+cu117

How to solve this issue?

ninoslavc commented 1 year ago

I have found the error. My y was a NumPy array of shape (2783,1) instead of (2783,)