>>> image = np.random.randint(10,size=(3,2,2,3))
>>> image[0][:,:,0]
array([[5, 5],
[0, 1]])
>>> image
array([[[[5, 9, 2],
[5, 5, 8]],
[[0, 8, 8],
[1, 7, 2]]],
[[[5, 0, 3],
[0, 0, 0]],
[[9, 4, 4],
[9, 0, 1]]],
[[[8, 2, 6],
[4, 9, 4]],
[[8, 4, 6],
[0, 6, 5]]]])
>>>
size(3,2,2,3)l类似图像数量3个,像素2*2,通道3
image[0][:,:,0]取出第一个图像的第一个通道值。
2. 将图像的三个通道值整合成一个列向量(也就是,一张图像由一个列向量表示),m个图像则有m个列向量
>>> image_flatten = image.reshape(image.shape[0],-1).T
>>> image_flatten.shape
(12, 3)
>>> image_flatten
array([[5, 5, 8],
[9, 0, 2],
[2, 3, 6],
[5, 0, 4],
[5, 0, 9],
[8, 0, 4],
[0, 9, 8],
[8, 4, 4],
[8, 4, 6],
[1, 9, 0],
[7, 0, 6],
[2, 1, 5]])
>>>
reshape(,-1)中-1参数的理解:https://blog.csdn.net/weixin_39449570/article/details/78619196