
Numpy
WHUAndGXUJavaBoy
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
np.hstack()和np.vstack()
https://blog.youkuaiyun.com/m0_37393514/article/details/79538748 np.hstack()和np.vstack()是numpy的两个拼接数组的方法 np.vstack():在竖直方向上堆叠 np.hstack():在水平方向上平铺 示例代码: import numpy as np arr1=np.array([1,2,3]) arr2=np.a...原创 2019-05-21 14:20:07 · 493 阅读 · 0 评论 -
关于ImportError: cannot import name '_validate_lengths'的解决方案
参考文章: https://blog.youkuaiyun.com/weixin_44508906/article/details/87347875 主要原因是numpy版本更新导致的,之前1.14.13版本正常,更新到1.16.2就报这个错误原创 2019-05-21 14:17:11 · 1011 阅读 · 0 评论 -
numpy数组中冒号的使用
示例代码: import numpy as np a = np.array([[1,2,3], [4,5,6]]) print(a[:,2]) #输出[3,6] a[:,2]的意思就是取a的所有行的第2列元素 同理 a[1,:]的结果为[1,2,3]原创 2019-05-22 11:59:01 · 892 阅读 · 0 评论 -
numpy的newaxis
newaxis的作用为给numpy数组增加新的维度 示例代码: import numpy as np a = np.array([1,2,3]) #a.shsape=(3,) a1 = a[np.newaxis,:] #a1.shape=(1,3) print(a1) #[[1 2 3]] a2 = a[:,np.newaxis] #a2.shape=(3,1) print(a2) 打印结果...原创 2019-05-22 12:16:59 · 191 阅读 · 0 评论 -
将带有字符型的numpy数组内容写入txt文件
示例代码: import numpy as np a = np.array([['a','b'], [1,2]]) np.savetxt("result1.txt", temp,fmt='%s %s',delimiter=' ') 结果:原创 2019-06-17 10:27:18 · 3505 阅读 · 0 评论 -
np.random.get_state()
state = np.random.get_state() 两个用法: 1、与np.random()函数一起使用,使得多次生成的随机数相同,示例代码如下: import numpy as np state = np.random.get_state() a = np.random.randint(10) b = np.random.randint(10) np.random.set_stat...原创 2019-06-27 22:14:52 · 682 阅读 · 0 评论