python - 理解pytorch预测中的TimeSeriesDataSet
问题描述
这是从 pytorch 预测教程中获取的代码示例:
# create dataset and dataloaders
max_encoder_length = 60
max_prediction_length = 20
training_cutoff = data["time_idx"].max() - max_prediction_length
context_length = max_encoder_length
prediction_length = max_prediction_length
training = TimeSeriesDataSet(
data[lambda x: x.time_idx <= training_cutoff],
time_idx="time_idx",
target="value",
categorical_encoders={"series": NaNLabelEncoder().fit(data.series)},
group_ids=["series"],
# only unknown variable is "value" - and N-Beats can also not take any additional variables
time_varying_unknown_reals=["value"],
max_encoder_length=context_length,
max_prediction_length=prediction_length,
)
validation = TimeSeriesDataSet.from_dataset(training, data, min_prediction_idx=training_cutoff + 1)
batch_size = 128
train_dataloader = training.to_dataloader(train=True, batch_size=batch_size, num_workers=0)
val_dataloader = validation.to_dataloader(train=False, batch_size=batch_size, num_workers=0)
我真的不明白验证数据集是如何根据时间索引完成的。我也不明白为什么教程中没有测试数据集。是出于特定原因吗?
解决方案
推荐阅读
- java - 如何从java应用程序调用javaBridge Main
- java - editText.setText(string) 不起作用,但 textView.setText(string) 总是有效,奇怪的区别
- c# - 缺少语言时如何处理后备?
- python - 我在 python tkinter gui 中找不到数据库连接
- multithreading - 事务范围 - “操作对事务状态无效”错误,每次都必须重新启动 DTC 服务
- indexing - 如何编写具有不同标准的 excel 索引匹配公式?
- git - 在 github 中需要 rebase 帮助
- html - 固定的css位置正在占用另一个div的边距
- c++ - 如何存储和调用变量参数函数和值向量?
- javascript - 在对象数组中使用条件将特定字符串添加到对象数据