python在TensorFlow搭建的环境下,所有数据的提取和Matlab的形式一致。
由于缺乏以往对高维案例的研究,我们第一次遇到了3D数据的提取,出现了一些困惑。
[En]
Due to the lack of previous research on high-dimensional cases, we encountered the extraction of 3D data for the first time, and there was some confusion.
以下是我对这方面的理解。
[En]
Here is my own understanding of this aspect.
import numpy as np
a = np.arange(60).reshape(3,4,5)
b1 = a[0::1,:]
print(a)
print(b2)
从该示例的结果可以发现:
[En]
From the results of the example, it can be found that:
首先,3D数据的显示和维度表示之间的关系:
[En]
First, the relationship between the display and dimensional representation of 3D data:
1: 维度表示信息的(n1, n2, n3)从前往后表示高维数据的”[]”的从外往里,很明显,最后的(n2, n3)表示最里层的矩阵为n2行n3列,外层的n1表示有多少个这样的矩阵。
二:重点解释 “::” 的含义
1:首先,该符号可解释为,设置等差数列中的公差,即
::a 表示第1个元素开始(对应第0个维度),每隔a个元素抽取一次数据
2:c::b则表示初始元素维度为c,公差为b
3.1: 还有一点困惑的地方为:
三维数组中,出现形如[::d, :]
的数据信息提取,它的具体解释为,第一个维度中以 ::d 进行数据的提取,剩下两个维度则不发生改变。以三维数组为例,是提取第几个矩阵的信息
3.2 若形如[:,::d] 等价于[:,::d,:]
即在第二个维度中以 ::d 的形式进行数据提取,以三维数组为例,是提取每个矩阵行的信息
3.3 若形如[:,:,::d]
即在第三个维度中以 ::d 的形式进行数据提取,以三维数组为例,是提取每个矩阵列的信息
具体的例子和结果可以自己去实践和体验。
[En]
Specific examples and results can be carried out and experienced by yourself.
Original: https://blog.csdn.net/jwbwang/article/details/121348558
Author: jwbwang
Title: python高维数组的提取
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/511886/
转载文章受原作者版权保护。转载请注明原作者出处!