我无法访问这个变量,因为 'Word2Vec' 对象没有属性 'history' 。我的模型由 lstm 和 word2vec 创建。
accuracy = model.history.history["accuracy"]
val_accuracy = model.history.history["val_accuracy"]
loss = model.history.history["loss"]
val_loss = model.history.history["val_loss"]
plt.plot(accuracy, label="accuracy")
plt.plot(val_accuracy, label="validation accuracy")
plt.ylabel("Accuracy")
plt.xlabel("Epoch")
plt.legend()
plt.show()
This is my word2vec object is :
model = Word2Vec(data_set, vector_size=embedding_size,
window=skip_window, negative=num_sampled, epochs=num_iter,
sg=1)
embeddings = model.wv
def save(embeddings):
dictionary = dict([(embeddings.index_to_key[i], i) for i in
range(len(embeddings.index_to_key))])
reverse_dictionary = dict(zip(dictionary.values(),
dictionary.keys()))
word2vec = {"dictionary": dictionary, "embeddings": embeddings,
"reverse_dictionary": reverse_dictionary}
with open(vec_dir, "wb") as f:
pickle.dump(word2vec, f)