1 Star 1 Fork 1

submitpaper/ST-HConv

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
load_data.py 985 Bytes
一键复制 编辑 原始数据 按行查看 历史
ChenSg 提交于 2022-09-21 15:38 . orig
import torch
import numpy as np
import pandas as pd
def load_matrix(file_path):
return pd.read_csv(file_path, header=None).values.astype(float)
def load_data(file_path, len_train, len_val):
df = pd.read_csv(file_path, header=None).values.astype(float)
train = df[: len_train]
val = df[len_train: len_train + len_val]
test = df[len_train + len_val:]
return train, val, test
def data_transform(data, n_his, n_pred, day_slot, device):
n_day = len(data) // day_slot
n_route = data.shape[1]
n_slot = day_slot - n_his - n_pred + 1
x = np.zeros([n_day * n_slot, 1, n_his, n_route])
y = np.zeros([n_day * n_slot, n_route])
for i in range(n_day):
for j in range(n_slot):
t = i * n_slot + j
s = i * day_slot + j
e = s + n_his
x[t, :, :, :] = data[s:e].reshape(1, n_his, n_route)
y[t] = data[e + n_pred - 1]
return torch.Tensor(x).to(device), torch.Tensor(y).to(device)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/submitpaper/st-hconv.git
git@gitee.com:submitpaper/st-hconv.git
submitpaper
st-hconv
ST-HConv
master

搜索帮助