问题描述
SciPy和Numpy都内置了用于奇异值分解(SVD)的函数.这些命令基本上是scipy.linalg.svd
和numpy.linalg.svd
.两者有什么区别?他们中的任何一个都比另一个更好吗?
Both SciPy and Numpy have built in functions for singular value decomposition (SVD). The commands are basically scipy.linalg.svd
and numpy.linalg.svd
. What is the difference between these two? Is any of them better than the other one?
推荐答案
来自常见问题页面,它说scipy.linalg
子模块为Fortran LAPACK库提供了更完整的包装器,而numpy.linalg
试图能够独立于LAPACK进行构建.
From the FAQ page, it says scipy.linalg
submodule provides a more complete wrapper for the Fortran LAPACK library whereas numpy.linalg
tries to be able to build independent of LAPACK.
对于svd
的不同实现,我做了一些基准函数,发现scipy.linalg.svd
比numpy对应的更快:
I did some benchmarks for the different implementation of the svd
functions and found scipy.linalg.svd
is faster than the numpy counterpart:
但是, jax 包裹了numpy,又名jax.numpy.linalg.svd
甚至更快:
However, jax wrapped numpy, aka jax.numpy.linalg.svd
is even faster:
可以在此处找到完整的基准测试笔记本.
Full notebook for the benchmarks are available here.
这篇关于SciPy SVD与Numpy SVD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!