Speicherfehler in Python mit Numpy-Array

Ich erhalte den folgenden Fehler für diesen Code:

model = lda.LDA(n_topics=15, n_iter=50, random_state=1)
model.fit(X)
topic_word = model.topic_word_
print("type(topic_word): {}".format(type(topic_word)))
print("shape: {}".format(topic_word.shape))
print ("\n")
n = 15
doc_topic=model.doc_topic_
for i in range(15):
    print("{} (top topic: {})".format(titles[i], doc_topic[0][i].argmax()))

topic_csharp=np.zeros(shape=[1,n])
np.copyto(topic_csharp,doc_topic[0][i])
for i, topic_dist in enumerate(topic_word):
    topic_words = np.array(vocab)[np.argsort(topic_dist)][:-(n+1):-1]
    print('*Topic {}\n- {}'.format(i, ' '.join(topic_words)))

Fehler ist:

Traceback (most recent call last):
File "C:\Users\csharp.py", line 56, in <module>
topic_words = np.array(vocab)[np.argsort(topic_dist)][:-(n+1):-1]
MemoryError

Das Dokument, das ich in das Modell einpasse, enthält ca. 1,50.000 Textzeilen. vocab_size: 558270 n_words: 13075390 (nach der Vorverarbeitung)

Wie kann ich diesen Fehler beheben?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage