鱼C论坛

 找回密码
 立即注册
查看: 1672|回复: 3

[已解决]numpy中empty的函数不生效

[复制链接]
发表于 2019-9-2 14:42:27 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
np.empty(6)
array([0., 0., 0., 0., 0., 0.])
#本应该是随机的没有具体数值,但是无论输入几次都是0
其他函数使用都是正常,就empty有问题
请大神们赐教

最佳答案
2019-9-2 14:51:22
empty, unlike zeros, does not set the array values to zero, and may therefore be marginally faster.
On the other hand, it requires the user to manually set all the values in the array, and should be used with caution.

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-9-2 14:51:22 | 显示全部楼层    本楼为最佳答案   
empty, unlike zeros, does not set the array values to zero, and may therefore be marginally faster.
On the other hand, it requires the user to manually set all the values in the array, and should be used with caution.

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-9-2 14:51:45 | 显示全部楼层
代码贴一下啊
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-2 14:53:43 | 显示全部楼层
塔利班 发表于 2019-9-2 14:51
empty, unlike zeros, does not set the array values to zero, and may therefore be marginally faster.  ...

感谢~发完帖子才发现不能在ones和zeros后面使用,不然数组内全是0或者1
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-2 08:57

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表