多維度圖像維度變換
- 當圖像對應的矩陣的維度爲[64, 64, 1, 4000],其中64×64表示圖像的大小,1表示圖像的通道數;4000表示圖像的張數;爲了將矩用於Tensorflow的輸入格式,即4000×64×64×1,使用np.transpose((3, 0,1, 2))來進行變換:
sc_test = sc_test.transpose((3, 0, 1, 2))
slope_test = slope_test.transpose((3, 0, 1, 2))
- 如果將兩個多爲矩陣拼接,使用 np.concatenate((a,b), axis = 3)
數組的維度a=[64, 64, 1, 5000]; b=[64, 64, 1, 5000];
在axis= 3 將a, b合併起來c=[64, 64, 1, 10000]
c = np.concatenate((a,b), axis = 3)