# 我利用numpy作为演示
import numpy as np
# 模拟t时刻路网流量矩阵,大小为100*100
t_clip = np.random.rand(100,100)
print(t_clip.shape) # (100, 100) 表示t时刻n*n的矩阵
(100, 100)
# 现在有多个n*n矩阵,也就是你划分出来的一个个大矩阵
t_clip_1 = np.random.rand(100,100)
t_clip_2 = np.random.rand(100,100)
t_clip_3 = np.random.rand(100,100)
# 得到了多个矩阵我们就将它拼接起来
# 将每一个(100,100)维度的矩阵,扩展成为(1,100,100)
t_clip = np.expand_dims(t_clip,axis=0)
t_clip_1 = np.expand_dims(t_clip_1,axis=0)
t_clip_2 = np.expand_dims(t_clip_2,axis=0)
t_clip_3 = np.expand_dims(t_clip_3,axis=0)
# (1,100,100)变成(T,100,100)
t_clip = np.concatenate((t_clip,t_clip_1),axis=0)
t_clip = np.concatenate((t_clip,t_clip_2),axis=0)
t_clip = np.concatenate((t_clip,t_clip_3),axis=0)
print(t_clip.shape) # 得到 (4, 100, 100)
# 将结果保存在numpy里
np.savez('./t_clip.npz', t_clip=t_clip)
(1, 100, 100)
(2, 100, 100)
(3, 100, 100)
(4, 100, 100)