In Numpy dimensions are called axes. The number of axes is rank.
In [3]: a.ndim # num of dimensions/axes, *Mathematics definition of dimension*
Out[3]: 2
轴/轴
在Numpy中,nth坐标表示一个array。多维数组每个轴可以有一个索引。
In [4]: a[1,0] # to index `a`, we specific 1 at the first axis and 0 at the second axis.
Out[4]: 3 # which results in 3 (locate at the row 1 and column 0, 0-based index)
形状
描述每个可用轴上有多少数据(或范围)。
In [5]: a.shape
Out[5]: (2, 2) # both the first and second axis have 2 (columns/rows/pages/blocks/...) data
如果输入不是numpy数组,而是列表列表,也可以使用
或者一对一对
它是^{} :
因此:
首先:
按照惯例,在Python世界中,
numpy
的快捷方式是np
,因此:第二:
在Numpy中,维度,轴/轴,形状是相关的,有时是相似的概念:
尺寸
在数学/物理中,维度或维度非正式地定义为指定空间内任何点所需的最小坐标数。但在Numpy中,根据numpy doc,它与轴/轴相同:
轴/轴
在Numpy中,nth坐标表示一个
array
。多维数组每个轴可以有一个索引。形状
描述每个可用轴上有多少数据(或范围)。
相关问题 更多 >
编程相关推荐