知行编程网知行编程网  2022-07-29 02:00 知行编程网 隐藏边栏 |   抢沙发  38 
文章评分 0 次,平均分 0.0

NumPy迎来重大版本更新,新增函数注释、滑动窗口视图功能,仅支持Python 3.7以上版本

杨净 发自 凹非寺    来自 | 量子位

最近,NumPy上线了最新版本——NumPy 1.20。

NumPy迎来重大版本更新,新增函数注释、滑动窗口视图功能,仅支持Python 3.7以上版本

作为Python的最重要的扩展程序库之一,也是入门机器学习的必备工具,该版本一经发布,就一度登上Hacker News等社区热搜榜单。

NumPy迎来重大版本更新,新增函数注释、滑动窗口视图功能,仅支持Python 3.7以上版本

这个版本号称是迄今为止规模最大版本,共合并了184人贡献的约684条PR,支持的Python版本是3.7-3.9。

注意哦,并不支持Python 3.6。

NumPy迎来重大版本更新,新增函数注释、滑动窗口视图功能,仅支持Python 3.7以上版本

此次版本的亮点如下:

  • NumPy函数注释。

  • 扩大SIMD使用范围,提高ufuncs的执行速度。

  • 文档改进,包括大约185个PR合并

  • 对即将到来的Cython 3.0提供初步支持。

  • 可为数组提供滑动窗口视图。

三大新功能

此次上线版本主要有三大新功能。

第一个,random.Generator类有一个新的permuted函数。

新函数与shuffle和permutation的不同之处在于,给定轴索引的子数组会被换算。

比如,现在就可以对一个二维数组的行或者列进行换算。

第二个,sliding_window_view,可为NumPy数组提供滑动窗口视图。

这一功能适用于多维度、可以明确指定轴、同一轴使用多次、移动多个元素的视图等用法。

NumPy迎来重大版本更新,新增函数注释、滑动窗口视图功能,仅支持Python 3.7以上版本

第三个,numpy.broadcast_shapes,一个面向用户的全新功能,从给定的形状元组相互广播中获得形状。

NumPy迎来重大版本更新,新增函数注释、滑动窗口视图功能,仅支持Python 3.7以上版本

除了新功能之外,还有一系列的改进。

比如,启动多平台SIMD编译器优化。

其中,包括新的构建参数、跨体系结构CPU调度程序、自动生成的新C标头、向numpy umath模块添加新属性,在PytestTester运行期间打印支持的CPU功能。

再比如,弃用np.int这一别名。

原本np.int是int的别名,但常常让新手困扰,而且原本也是出于历史原因而存在。

除了np.int外,还有一个不推荐使用的别名名单。(其中,第三列为备用NumPy名称)

NumPy迎来重大版本更新,新增函数注释、滑动窗口视图功能,仅支持Python 3.7以上版本

以及,还有mode 和 searchside的inexact match、numpy.dual模块都被弃用。

对于新版本的发布,有不少网友表示很期待里面中的新功能。

比如,类型注释。

NumPy迎来重大版本更新,新增函数注释、滑动窗口视图功能,仅支持Python 3.7以上版本

类型注释对我来很重要。如果你比较在意SIMD,或许可以考虑Julia。

还有网友pick了“滑动窗口视图”这一新功能。

在分析数据时经常使用滑动窗口,以前可以使用as_strided的方式来实现,但这个方法太麻烦,现在这一新功能显然更简单。

NumPy迎来重大版本更新,新增函数注释、滑动窗口视图功能,仅支持Python 3.7以上版本

参考链接:
https://NumPy.org/doc/1.20/release/1.20.0-notes.html#deprecations
https://news.ycombinator.com/item?id=25977977

<pre><section style="letter-spacing: 0.544px;white-space: normal;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;"><section powered-by="xiumi.us"><section style="margin-top: 15px;margin-bottom: 25px;opacity: 0.8;"><section><section style="letter-spacing: 0.544px;"><section powered-by="xiumi.us"><section style="margin-top: 15px;margin-bottom: 25px;opacity: 0.8;"><section><section style="margin-bottom: 15px;padding-right: 0em;padding-left: 0em;color: rgb(127, 127, 127);font-size: 12px;font-family: sans-serif;line-height: 25.5938px;letter-spacing: 3px;text-align: center;"><span style="color: rgb(0, 0, 0);"><strong><span style="font-size: 16px;font-family: 微软雅黑;caret-color: red;">为您推荐</span></strong></span></section><p style="margin: 5px 16px;padding-right: 0em;padding-left: 0em;font-family: sans-serif;letter-spacing: 0px;opacity: 0.8;line-height: normal;text-align: center;">一个算法工程师的日常是怎样的?</p><p style="margin: 5px 16px;padding-right: 0em;padding-left: 0em;font-family: sans-serif;letter-spacing: 0px;opacity: 0.8;line-height: normal;text-align: center;">彻底搞懂机器学习中的正则化<br  /></p><section style="margin-top: 5px;margin-bottom: 5px;padding-right: 0em;padding-left: 0em;min-height: 1em;font-family: sans-serif;letter-spacing: 0px;opacity: 0.8;line-height: normal;text-align: center;"><span style="font-size: 14px;">13个算法工程师必须掌握的PyTorch Tricks</span></section><section style="margin-top: 5px;margin-bottom: 5px;padding-right: 0em;padding-left: 0em;min-height: 1em;font-family: sans-serif;letter-spacing: 0px;opacity: 0.8;line-height: normal;text-align: center;"><span style="font-size: 14px;">吴恩达上新:生成对抗网络(GAN)专项课程</span></section><section style="margin-top: 5px;margin-bottom: 5px;padding-right: 0em;padding-left: 0em;min-height: 1em;font-family: sans-serif;letter-spacing: 0px;opacity: 0.8;line-height: normal;text-align: center;">从SGD到NadaMax,十种优化算法原理及实现</section></section></section></section></section></section></section></section></section>

NumPy迎来重大版本更新,新增函数注释、滑动窗口视图功能,仅支持Python 3.7以上版本


本篇文章来源于: 深度学习这件小事

本文为原创文章,版权归所有,欢迎分享本文,转载请保留出处!

知行编程网
知行编程网 关注:1    粉丝:1
这个人很懒,什么都没写

发表评论

表情 格式 链接 私密 签到
扫一扫二维码分享