Sogou 텍스트 분류 데이터 세트의 토큰을 나타내는 목록이 상당히 많습니다. 남은 12 기가의 램을 가지고 450 000의 전체 훈련 세트를 처리 할 수 있지만 목록 목록에서 numpy.save()를 호출하면 메모리 사용량이 두 배로 늘어나고 메모리가 부족한 것 같습니다.numpy로 목록을 저장할 때 메모리가 부족합니다.
왜 이런가요? numpy.save는 저장하기 전에 목록을 변환하지만 더 많은 메모리를 사용하여 목록을 보유합니까?
이 목록의 목록을 저장하는 다른 방법이 있습니까? 내가 할 수 피클 인수에서 판단 피클 프로토콜을 사용하여 저장 NumPy와 생각 : https://docs.scipy.org/doc/numpy/reference/generated/numpy.save.html
print "Collecting Raw Documents, tokenize, and remove stop words"
df = pd.read_pickle(path + dataSetName + "Train")
frequency = defaultdict(int)
gen_docs = []
totalArts = len(df)
for artNum in range(totalArts):
if artNum % 2500 == 0:
print "Gen Docs Creation on " + str(artNum) + " of " + str(totalArts)
bodyText = df.loc[artNum,"fullContent"]
bodyText = re.sub('<[^<]+?>', '', str(bodyText))
bodyText = re.sub(pun, " ", str(bodyText))
tmpDoc = []
for w in word_tokenize(bodyText):
w = w.lower().decode("utf-8", errors="ignore")
#if w not in STOPWORDS and len(w) > 1:
if len(w) > 1:
#w = wordnet_lemmatizer.lemmatize(w)
w = re.sub(num, "number", w)
tmpDoc.append(w)
frequency[w] += 1
gen_docs.append(tmpDoc)
print len(gen_docs)
del df
print "Saving unfiltered gen"
dataSetName = path + dataSetName
np.save("%s_lemmaWords_noStop_subbedNums.npy" % dataSetName, gen_docs)
이러한 "토큰"은 무엇입니까? 숫자 데이터? 아니면 더 복잡한 객체입니까? – bnaecker
문자열은 각각 하나의 단어입니다. – Kevinj22
왜 numpy를 사용하여 목록의 목록을 저장하고 있습니까? 그것이 의미가 없기 때문에 배열을 먼저 만들려고하면 놀라지 않을 것입니다. –