shape 应用
>>> x = numpy.arange(6).reshape(-1,3)
>>> x
array([[0, 1, 2],
[3, 4, 5]])
>>> x.shape
(2, 3)
>>> x.shape[0]
2
>>> x[0].shape
(3,)
省略号应用
>>> x = numpy.arange(12).reshape(-1,4)
>>> x
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
>>> x[...,1]
array([1, 5, 9])
>>> x[1,...]
array([4, 5, 6, 7])
>>> x[...,1:]
array([[ 1, 2, 3],
[ 5, 6, 7],
[ 9, 10, 11]])
>>> x[:2,...]
array([[0, 1, 2, 3],
[4, 5, 6, 7]])
np.transpose
>>>a = np.array([[1, 2], [3, 4]])
>>>a
array([[1, 2],
[3, 4]])
>>>np.transpose(a)
array([[1, 3],
[2, 4]])
>>>a = np.array([1, 2, 3, 4])
>>>a
array([1, 2, 3, 4])
>>>np.transpose(a)
array([1, 2, 3, 4])
>>>a = np.ones((1, 2, 3))
>>>np.transpose(a, (1, 0, 2)).shape
(2, 1, 3)
>>>a = np.ones((2, 3, 4, 5))
>>>np.transpose(a).shape
(5, 4, 3, 2)