【发布时间】:2022-01-14 14:53:15
【问题描述】:
我正在处理多时相、多光谱的卫星图像。数据以 ((n_bands x n_timesteps), height, width) 的形式存储为 geotiff。我需要为 ML 模型训练重塑数组,其中图像中的每个像素都是一个“样本”。因此,训练数组的形状为(n_samples x n_timesteps x n_bands)。
假设以下数组和相关变量。还假设数据集中的波段数为 12,时间步长为 4。因此,数组的第一维为 12*4 = 48。
x = np.random.rand(48, 512, 512)
width = x.shape[1]
height = x.shape[2]
n_samples = width * height
n_bands = 12
n_timesteps = x.shape[0] / n_bands
将数组x 重塑为x_reshape 以使x_reshape.shape 返回的最佳方法是:
(n_samples, n_timesteps, n_bands)
确保保持数据的正确顺序,以便x_reshape[0] 的切片是形状为(n_timesteps x n_features) 的数据集的单个“样本”?
【问题讨论】: