Time-LLM/data_provider_pretrain/data_factory.py
2024-02-09 01:16:10 +11:00

49 lines
1.3 KiB
Python

from torch.utils.data import DataLoader
from data_provider_pretrain.data_loader import Dataset_ETT_hour, Dataset_ETT_minute
data_dict = {
'ETTh1': Dataset_ETT_hour,
'ETTh2': Dataset_ETT_hour,
'ETTm1': Dataset_ETT_minute,
'ETTm2': Dataset_ETT_minute,
}
def data_provider(args, data, data_path, pretrain=True, flag='train'):
Data = data_dict[data]
timeenc = 0 if args.embed != 'timeF' else 1
percent = args.percent
if flag == 'test':
shuffle_flag = False
drop_last = True
batch_size = args.batch_size
freq = args.freq
else:
shuffle_flag = True
drop_last = True
batch_size = args.batch_size
freq = args.freq
data_set = Data(
root_path=args.root_path,
data_path=data_path,
flag=flag,
size=[args.seq_len, args.label_len, args.pred_len],
features=args.features,
target=args.target,
timeenc=timeenc,
freq=freq,
percent=percent,
seasonal_patterns=args.seasonal_patterns,
pretrain=pretrain
)
data_loader = DataLoader(
data_set,
batch_size=batch_size,
shuffle=shuffle_flag,
num_workers=args.num_workers,
drop_last=drop_last)
return data_set, data_loader