Closed YYKKKKXX closed 1 year ago
Hi @YYKKKKXX ,
I don't know what causing your issue. I've tried to reproduce it with some dummy data but I couldn't.
Are you using the latest version of tsai
(>=0.3.5)?
Here's what I used:
from tsai.basics import *
my_setup()
# output
# os : Linux-5.10.147+-x86_64-with-glibc2.31
# python : 3.9.16
# tsai : 0.3.5
# fastai : 2.7.11
# fastcore : 1.5.28
# torch : 1.13.1+cu116
# cpu cores : 1
# threads per cpu : 2
# RAM : 12.68 GB
# GPU memory : N/A
from tsai.basics import *
from tsai.models.TST import TST
X_df = np.random.rand(6, 1, 66)
y_df = np.random.rand(6)
splits = get_splits(y_df, valid_size=.2, stratify=False, random_state=23, shuffle=True, show_plot=False)
check_data(X_df, y_df, splits)
tfms = [None, [TSRegression()]]
batch_tfms = TSStandardize(by_sample=True, by_var=True)
dls = get_ts_dls(X_df, y_df, splits=splits, tfms=tfms, batch_tfms=batch_tfms, bs=2)
dls.show_batch()
tst = TST(1,1,66)
learn = Learner(dls, tst, metrics=[mae, rmse, mse, msle, mape])
learn.summary()
learn.fit_one_cycle(10, 1e-3)
Alternative (and simpler) ways to do the same are:
from tsai.basics import *
X_df = np.random.rand(6, 1, 66)
y_df = np.random.rand(6)
splits = get_splits(y_df, valid_size=.2, stratify=False, random_state=23, shuffle=True, show_plot=False)
check_data(X_df, y_df, splits)
tfms = [None, [TSRegression()]]
batch_tfms = TSStandardize(by_sample=True, by_var=True)
dls = get_ts_dls(X_df, y_df, splits=splits, tfms=tfms, batch_tfms=batch_tfms, bs=2)
dls.show_batch()
learn = ts_learner(dls, arch="TST", metrics=[mae, rmse, mse, msle, mape])
learn.summary()
learn.fit_one_cycle(10, 1e-3)
or this:
from tsai.basics import *
X_df = np.random.rand(6, 1, 66)
y_df = np.random.rand(6)
splits = get_splits(y_df, valid_size=.2, stratify=False, random_state=23, shuffle=True, show_plot=False)
check_data(X_df, y_df, splits)
tfms = [None, [TSRegression()]]
batch_tfms = TSStandardize(by_sample=True, by_var=True)
learn = TSRegressor(X_df, y_df, splits=splits, tfms=tfms, batch_tfms=batch_tfms, bs=2, arch="TST", metrics=[mae, rmse, mse, msle, mape])
learn.dls.show_batch()
learn.summary()
learn.fit_one_cycle(10, 1e-3)
Hi @oguiza
Thanks for the reply and suggestion. I am using the latest version of tsai
= 0.3.5
And later, I used your code to see if it can work, but I have the same error as before.
However, the learn.summary()
shows no error, and all layers are trainable:
TST (Input shape: 2 x 1 x 66)
============================================================================
Layer (type) Output Shape Param # Trainable
============================================================================
2 x 66 x 128
Linear 256 True
Dropout
Linear 16384 True
Linear 16384 True
Linear 16384 True
Linear 16384 True
Dropout
____________________________________________________________________________
2 x 128 x 66
Transpose
BatchNorm1d 256 True
____________________________________________________________________________
2 x 66 x 128
Transpose
____________________________________________________________________________
2 x 66 x 256
Linear 33024 True
GELU
Dropout
____________________________________________________________________________
2 x 66 x 128
Linear 32896 True
Dropout
____________________________________________________________________________
2 x 128 x 66
Transpose
BatchNorm1d 256 True
____________________________________________________________________________
2 x 66 x 128
Transpose
Linear 16384 True
Linear 16384 True
Linear 16384 True
Linear 16384 True
Dropout
____________________________________________________________________________
2 x 128 x 66
Transpose
BatchNorm1d 256 True
____________________________________________________________________________
2 x 66 x 128
Transpose
____________________________________________________________________________
2 x 66 x 256
Linear 33024 True
GELU
Dropout
____________________________________________________________________________
2 x 66 x 128
Linear 32896 True
Dropout
____________________________________________________________________________
2 x 128 x 66
Transpose
BatchNorm1d 256 True
____________________________________________________________________________
2 x 66 x 128
Transpose
Linear 16384 True
Linear 16384 True
Linear 16384 True
Linear 16384 True
Dropout
____________________________________________________________________________
2 x 128 x 66
Transpose
BatchNorm1d 256 True
____________________________________________________________________________
2 x 66 x 128
Transpose
____________________________________________________________________________
2 x 66 x 256
Linear 33024 True
GELU
Dropout
____________________________________________________________________________
2 x 66 x 128
Linear 32896 True
Dropout
____________________________________________________________________________
2 x 128 x 66
Transpose
BatchNorm1d 256 True
____________________________________________________________________________
2 x 66 x 128
Transpose
GELU
____________________________________________________________________________
2 x 8448
Flatten
____________________________________________________________________________
2 x 1
Linear 8449 True
____________________________________________________________________________
Total params: 404,609
Total trainable params: 404,609
Total non-trainable params: 0
Optimizer used: <function Adam at 0x0000024DB47B6310>
Loss function: FlattenedLoss of MSELoss()
Callbacks:
- TrainEvalCallback
- CastToTensor
- Recorder
- ProgressCallback
Thank you very much for looking at this.
That's very strange. You're saying that if you run the same code I used you are getting the issue?
from tsai.basics import *
X_df = np.random.rand(6, 1, 66)
y_df = np.random.rand(6)
splits = get_splits(y_df, valid_size=.2, stratify=False, random_state=23, shuffle=True, show_plot=False)
check_data(X_df, y_df, splits)
tfms = [None, [TSRegression()]]
batch_tfms = TSStandardize(by_sample=True, by_var=True)
learn = TSRegressor(X_df, y_df, splits=splits, tfms=tfms, batch_tfms=batch_tfms, bs=2, arch="TST", metrics=[mae, rmse, mse, msle, mape])
learn.dls.show_batch()
learn.summary()
learn.fit_one_cycle(10, 1e-3)
Could you please run this code and post the output here?
from tsai.basics import *
my_setup()
Have you set up a new environment to run tsai
? Can you run your code in any other environment (like Google Colab) or create a new environment?
Hi @oguiza
I recently tried to degrade my tsai
version=0.3.4, and it finally work out.
now the output my_setup()
:
os : Windows-10-10.0.22000-SP0
python : 3.8.13
tsai : 0.3.4
fastai : 2.7.11
fastcore : 1.5.28
torch : 1.13.1+cu117
device : 1 gpu (['NVIDIA GeForce RTX 3060 Laptop GPU'])
cpu cores : 14
threads per cpu : 1
RAM : 15.73 GB
GPU memory : [6.0] GB
Thank you for looking at this.
I'll close this issue based on the feedback provided.
Hello,
I meet an error with using tsai. I was trying to do a regression task, and the error occured. But actually my data don't have the type 'string'.
This is the error stack:
My code is:
And the output of my
check_data(X_df, y_df, splits)
:Thanks.