IPython 并行计算深入解析
1. IPython 并行计算基础操作
在 IPython 中进行并行计算时,一些特殊的魔法命令非常有用。比如,在某些情况下不会返回任何结果,但每个引擎都有自己的数组对象副本,我们可以对其进行操作。
In [27]: %px numpy.linalg.eigvals(arrays)
Out[0:7]: array([ 1.49907907, 0.28987838, 0.49496096])
Out[1:7]: array([ 1.43756182, 0.27747814, 0.45153931])
Out[2:7]: array([ 1.51325036+0.j, -0.06614375+0.30396195j, -0.06614375-0.30396195j])
Out[3:7]: array([ 1.71117020+0.j, -0.13081468+0.42304986j, -0.13081468-0.42304986j])
魔法命令还可以远程运行,例如在多个引擎上启动 %pylab 魔法:
In [44]: %px %pylab inline
[stdout:0] Populating the interactive namespace from numpy and matplotlib
[stdout:1] Populating the interactive namespace from numpy and matplotlib
[stdout:
超级会员免费看
订阅专栏 解锁全文

521

被折叠的 条评论
为什么被折叠?



