Numpy
yzpfyang
这个作者很懒,什么都没留下…
展开
-
Numpy dot()
dot()返回数组的点积示例代码:常数:两数相乘In [2]: a = 2 In [3]: b = 3 In [4]: n...原创 2020-02-06 19:17:38 · 123 阅读 · 0 评论 -
Numpy 中np.eye np.zeros np.ones
np.eye : 生成单位矩阵np.zeros :生成全0矩阵np.ones:生成全1矩阵示例代码如下:In [29]: a = np.eye(3) In [30]: a ...原创 2020-02-02 17:26:18 · 561 阅读 · 0 评论 -
Python中 [:,n] [n,:] [a:b,:] [:,a:b]
[:,n] [n,:] [a:b,:] [:,a:b] 都是Numpy中array的一种写法,其中:[:,n] :表示二维数组的第n列[n,:] :表示二维数组的第n行[a:b,:] :表示二维数组的第a至b行(包含a不包含b)[:,a:b] :表示二维数组的第a至b列(包含a不包含b)示例代码如下:In [1]: import numpy as np ...原创 2020-02-02 17:09:24 · 3140 阅读 · 0 评论 -
Python shape 和 reshape()
shape:查看数据有多少行多少列reshape():重组array的函数1. shapeimport numpy as npa = np.array([1,2,3,4,5,6,7,8]) #一维数组print(a.shape[0]) #值为8,因为有8个数据print(a.shape[1]) #IndexError: tuple index out of rangea = ...转载 2020-01-31 23:04:48 · 200 阅读 · 0 评论 -
Numpy:np.expand_dims()&np.argmax() 用法
np.expand_dims:用于扩展数组的形状原始数组In [1]: import numpy as np ...原创 2020-01-30 20:44:54 · 801 阅读 · 0 评论 -
Numpy concatenate 函数用法
numpy.concatenate((a1, a2, …), axis=0)Join a sequence of arrays along an existing axis.(按轴axis连接array组成一个新的array)The arrays must have the same shape, except in the dimension corresponding to axisax...原创 2020-01-30 16:47:52 · 1819 阅读 · 0 评论 -
Numpy tolist() 用法
tolist()作用:将矩阵(matrix)和数组(array)转化为列表。示例代码:>>> from numpy import *>>> a1 = [[1,2,3],[4,5,6]] #列表>>> a2 = array(a1) #数组>>> a2array([[1, 2, 3], [4, 5, 6]...原创 2020-01-30 15:58:03 · 9411 阅读 · 0 评论