我试图sklearn.decomposition.TruncatedSVD()在2台不同的计算机上运行,并了解性能差异.
电脑1(Windows 7,物理电脑)
OS Name Microsoft Windows 7 Professional
System Type x64-based PC
Processor Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz, 3401 Mhz, 4 Core(s),
8 Logical Installed Physical Memory (RAM) 8.00 GB
Total Physical Memory 7.89 GB
Run Code Online (Sandbox Code Playgroud)
电脑2(Debian,在亚马逊云上)
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
width: 64 bits
capabilities: ldt16 vsyscall32
*-core
description: Motherboard
physical id: 0
*-memory
description: System memory
physical id: 0
size: 29GiB
*-cpu
product: Intel(R) Xeon(R) CPU …Run Code Online (Sandbox Code Playgroud) 我正在尝试计算两个大小分别为 (162225, 10000) 和 (10000, 100) 的 numpy 数组的点积。但是,如果我调用 numpy.dot(A, B) 则会发生 MemoryError 。然后,我尝试编写我的实现:
def slower_dot (A, B):
"""Low-memory implementation of dot product"""
#Assuming A and B are of the right type and size
R = np.empty([A.shape[0], B.shape[1]])
for i in range(A.shape[0]):
for j in range(B.shape[1]):
R[i,j] = np.dot(A[i,:], B[:,j])
return R
Run Code Online (Sandbox Code Playgroud)
它工作得很好,但当然很慢。您知道 1)此行为背后的原因是什么以及 2)我如何规避/解决该问题吗?
我在一台配备 64 位、16GB 内存、运行 Ubuntu 14.10 的计算机上使用 Python 3.4.2(64 位)和 Numpy 1.9.1。