Я пытаюсь реализовать пример проекта на DZone (https://dzone.com/articles/cv-r-cvs-retrieval-system-based-on-job-description) и сталкиваюсь с проблемой. В этом случае я установил
dir_pca_we_EWE = 'pickle_model_pca.pkl'
и выполняю следующее:
def reduce_dimensions_WE(dir_we_EWE, dir_pca_we_EWE):
m1 = KeyedVectors.load_word2vec_format('./wiki.en/GoogleNews.bin', binary=True)
model1 = {}
# normalize vectors
for string in m1.wv.vocab:
model1[string] = m1.wv[string] / np.linalg.norm(m1.wv[string])
# reduce dimensionality
pca = decomposition.PCA(n_components=200)
pca.fit(np.array(list(model1.values())))
model1 = pca.transform(np.array(list(model1.values())))
i = 0
for key, value in model1.items():
model1[key] = model1[i] / np.linalg.norm(model1[i])
i = i + 1
with open(dir_pca_we_EWE, 'wb') as handle:
pickle.dump(model1, handle, protocol=pickle.HIGHEST_PROTOCOL)
return model1
Это приводит к следующей ошибке:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 12, in reduce_dimensions_WE
AttributeError: 'numpy.ndarray' object has no attribute 'items'
Как всегда, вся помощь очень ценится!