问题
I have a list with 482000
entries. The structure of the array is like this:
X_docs = [array([0., 0., 0., ..., 0., 0., 0.]),
array([0.60205999, 0.60205999, 0.47712125, ..., 0. , 0. ,0.])]
each array have 5000
entries. so in the end we have 482000 * 5000
.
Then I need to apply np.r
over it like this:
np.r_[X_docs]
When it reaches this line it raises this error:
MemoryError
I dont know how to fix this? is there any limitation regarding the numpy thing? I have 32 gig ram. I even tried to run it in AWS Amazon sagemaker(Free version). there it still raises error.
Update 1
This is the whole code before reaching the np part:
corpus = load_corpus(args.input)
n_vocab, docs = len(corpus['vocab']),
corpus['docs'] corpus.clear()
# save memory
doc_keys = docs.keys()
X_docs = []
for k in doc_keys:
X_docs.append(vecnorm(doc2vec(docs[k], n_vocab), 'logmax1', 0))
del docs[k] X_docs = np.r_[X_docs]
来源:https://stackoverflow.com/questions/57814074/how-to-fix-memory-error-while-using-np-r