0

我正在尝试使用Stephan Marslands 2D 自组织图(结合主成分分析

import som as sm
#put it into som
def som_algorithm(inputs,nIterations,x=0,y=0):
    print "Running Self-Organizing Map!"
    if x == 0 and y == 0:
        y = len(inputs[0])
        x = len(inputs)
    print "x axis is " + str(x) + " / y axis is " + str(y)
    som = sm.som(x,y,inputs)
    som.somtrain(inputs, nIterations)
    print som.somfwd(inputs)

som_algorithm(training, 100)

并根据我预处理后的数据集,产生此错误

Running Self-Organizing Map!
x axis is 600 / y axis is 173
Traceback (most recent call last):
  File "\source\bag_of_words.py", line 112, in <module>
som_algorithm(training, 100)
  File "\source\bag_of_words.py", line 87, in som_algorithm
som = sm.som(x,y,inputs)
  File "\som\__init__.py", line 44, in __init__
self.mapDist = zeros((self.x*self.y,self.x*self.y))
MemoryError

目前,myY表示每个数组的元素数量(数组维度包含在较大维度中),myX表示包含较小数组维度的较大维度。什么可能导致此内存错误?

4

1 回答 1

2

该代码试图创建一个形状为 x*y x*y 的零数组。那是 10774440000 个元素。数组中的每个值都是 8 个字节(双精度)。超过 80 GB。您只是内存不足。

于 2012-10-10T00:47:47.600 回答