np.dot(a,b) 矩阵相乘
X.transpose() np里的转置
np.diag()用法如下:
>>> x
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
>>>
>>> np.diag(x)
array([0, 4, 8])
>>> np.diag(x, k=1)
array([1, 5])
>>> np.diag(x, k=-1)
array([3, 7])
>>>
>>> np.diag(np.diag(x))
array([[0, 0, 0],
[0, 4, 0],
[0, 0, 8]])
numpy.split(ary, indices_or_sections, axis=0)
>>> x = np.arange(9.0)
>>> np.split(x, 3)
[array([ 0., 1., 2.]), array([ 3., 4., 5.]), array([ 6., 7., 8.])]
>>>
>>> x = np.arange(8.0)
>>> np.split(x, [3, 5, 6, 10])
[array([ 0., 1., 2.]),
array([ 3., 4.]),
array([ 5.]),
array([ 6., 7.]),
array([], dtype=float64)]
[source][np.mean(v) for k,v in sorted(a.items())]
对字典的每个关键字后的数组求均值,得到一个新list
>>> a={1:[1,2,3],3:[1,8]}
>>> [np.mean(v) for k,v in sorted(a.items())]
[2.0, 4.5]
numpy.std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False)[source]
The standard deviation is the square root of the average of the squared deviations from the mean, i.e., std = sqrt(mean(abs(x - x.mean())**2)).
>>> a = np.array([[1, 2], [3, 4]])
>>> np.std(a)
1.1180339887498949
>>> np.std(a, axis=0)
array([ 1., 1.])
>>> np.std(a, axis=1)
array([ 0.5, 0.5])
In single precision, std() can be inaccurate:
>>>
>>> a = np.zeros((2, 512*512), dtype=np.float32)
>>> a[0, :] = 1.0
>>> a[1, :] = 0.1
>>> np.std(a)
0.45000005
Computing the standard deviation in float64 is more accurate:
>>>
>>> np.std(a, dtype=np.float64)
0.44999999925494177