![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
numpy
千千Sama
这个作者很懒,什么都没留下…
展开
-
np.c_,np.r_用法
np.c_[a,b]:按列连接矩阵np.r_[a,b]:按行连接矩阵import numpy as npa = np.array([1, 2, 3])b = np.array([4, 5, 6])r = np.r_[a,b] # a,b按行(row)连接c = np.c_[a,b] # a,b按列(column)连接print("r:\n",r)print("c:\n",c)...原创 2018-11-19 16:15:53 · 235 阅读 · 0 评论 -
np.newaxis终极解释
例import numpy as npx = np.arange(3)print('x:\n', x)print('x.shape=', x.shape, '\n******************')print('x[:, np.newaxis]:\n', x[:, np.newaxis])print('x[:, np.newaxis].shape=', x[:, np.new...原创 2018-12-31 02:05:34 · 3503 阅读 · 3 评论 -
numpy中,冒号(:)的作用总结
结论2个作用①全部选中matrix1[1, :]表示matrix的第1行的所有元素②表示区间matrix1[1, 0:3]表示matrix的第1行的索引为**[0, 3)**的元素import numpy as npmatrix1 = np.zeros([3,4])print(matrix1)matrix1[1, :] = [1, 2, 3, 4] # 把matrix...原创 2019-05-02 21:08:25 · 3498 阅读 · 0 评论 -
np.random.uniform()用法
官方文档:https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.uniform.htmlnumpy.random.uniform(low=0.0, high=1.0, size=None)从[low, high])中均匀取值,没有任何参数的话,是从[0, 1)...原创 2019-05-02 21:25:08 · 15999 阅读 · 0 评论 -
np.random.randint()用法
官网文档:https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.randint.htmlnumpy.random.randint(low, high=None, size=None, dtype='l')从[low,high)中随机生成整数。若high=None,则从[0,low)生成...原创 2019-05-02 22:14:15 · 7424 阅读 · 0 评论 -
np.argmax()用法
官网文档:https://docs.scipy.org/doc/numpy-1.15.1/reference/generated/numpy.argmax.htmlnumpy.argmax(a, axis=None, out=None)[source]默认情况下axis=None,返回的是将数组平坦后的索引。import numpy as npmatrix1 = np.array([[...原创 2019-05-02 22:24:54 · 1159 阅读 · 0 评论 -
np.random.choice()用法
官网文档:https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.choice.htmlnumpy.random.choice(a, size=None, replace=True, p=None)从a中,按照size的shape提取样本。其中a若是array,则抽样元素,若是整数,则从np.arange(a)中抽...原创 2019-05-02 23:57:38 · 5857 阅读 · 2 评论