ASTGCN

sample = []  # [(week_sample),(day_sample),(hour_sample),target,time_sample]
sample.append(hour_sample)  # (1, vertices, features, sequences)
time_sample  # [[14]]

用当前12小时的数据预测下一12小时的数据

用到num_of_weeks, num_of_days, num_of_hours 3个维度的信息

train_x.shape
Out[8]: (10181, 307, 3, 12)
# (sequences, vertices, features, sub_sequences)

顶点信息

train_x[0,:,0,0]
Out[9]: 
array([ 62.,  56.,  90.,  32.,  19.,  68.,  24.,  24.,  31.,  31.,  90.,
        35., 124.,  36.,  27.,  37.,  68.,  91.,  75.,  71.,  30.,  21.,
        16.,  30.,  36.,  37.,  82.,  17., 120.,  72.,  60.,  14.,  97.,
        69.,  50.,  33.,  38.,  42.,  31.,  93.,  47., 255.,  85.,  83.,

特征信息

train_x[0,0,:,0]
Out[10]: array([6.20e+01, 7.70e-03, 6.79e+01])

all_samples = [[hour_sample, target, timestamp]]

train_x = np.concatenate(training_set[:-2], axis=-1) # (B,N,F,T') == train_x = np.concatenate([training_set[0]], axis=-1)

training_set[0].shape
Out[17]: (10181, 307, 3, 12)
training_set[1].shape
Out[18]: (10181, 307, 12)
training_set[2].shape
Out[19]: (10181, 1)

所以0 1 2 三个特征到底啥意思
flow, occupy, speed

np.expand_dims(target, axis=0).transpose((0, 2, 3, 1))[:, :, 0, :]
Out[17]: 
array([[[162., 126., 135., ..., 111., 116.,  96.],
        [102., 127., 129., ..., 128.,  93.,  82.],
        [ 96., 109.,  66., ...,  78., 146.,  92.],
        ...,
        [173., 154., 173., ..., 133., 127., 120.],
        [ 96.,  88.,  62., ...,  57.,  70.,  70.],
        [ 83., 100., 102., ..., 100.,  74.,  84.]]])
np.expand_dims(target, axis=0).transpose((0, 2, 3, 1))[:, :, 1, :]
Out[18]: 
array([[[0.0435, 0.0165, 0.0179, ..., 0.015 , 0.0146, 0.0127],
        [0.0246, 0.0348, 0.0319, ..., 0.0296, 0.0213, 0.0219],
        [0.016 , 0.0176, 0.0112, ..., 0.0127, 0.0238, 0.015 ],
        ...,
        [0.0292, 0.0255, 0.0302, ..., 0.022 , 0.0217, 0.0202],
        [0.0159, 0.0146, 0.01  , ..., 0.0097, 0.0116, 0.0113],
        [0.0205, 0.0258, 0.0259, ..., 0.0252, 0.018 , 0.0213]]])
np.expand_dims(target, axis=0).transpose((0, 2, 3, 1))[:, :, 2, :]
Out[19]: 
array([[[59. , 63.5, 64.6, ..., 67.5, 66.2, 67. ],
        [60.5, 58.9, 59.1, ..., 61.6, 62.5, 59.6],
        [67.9, 67.8, 68.2, ..., 68.7, 68.2, 68.2],
        ...,
        [66.2, 67. , 65.8, ..., 67.7, 67.2, 66.9],
        [68.9, 68.8, 68.7, ..., 68. , 69. , 69. ],
        [68.2, 68.2, 68. , ..., 68.7, 68.9, 68.5]]])
train_x.shape
Out[2]: (10181, 307, 3, 12)
val_x.shape
Out[3]: (3394, 307, 3, 12)
test_x.shape
Out[4]: (3394, 307, 3, 12)

看到归一化函数prepareData.normalizationmean = train.mean(axis=(0,1,3), keepdims=True)

看到axis=2的轴是特征轴,所以对每列特征分别进行归一化

你可能感兴趣的:(GNN)