1.假如我有一个二维数组:
[[0,1,2],[3,4,5],[6,7,8],[9,10,11]]
那么这里的轴axis怎么理解。axis在上面的数组中最大是多少。我没有看懂英文的教程,请详细解释一下。谢谢。
PHP中文网2017-04-18 09:33:08
axis means axis, number axis, and
corresponds to the dimension in a multi-dimensional array.
Your example is a 4 x 3 two-dimensional array with 2 axes: axis 0 and axis 1
>>> import numpy as np
>>> a = np.array([[0,1,2],[3,4,5],[6,7,8],[9,10,11]])
>>> a
array([[ 0, 1, 2],
[ 3, 4, 5],
[ 6, 7, 8],
[ 9, 10, 11]])
>>> a.shape
(4, 3)
>>> a.ndim
2
>>>