Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

add save/load dict_and_embedding for word2vector#410

Merged
jacquesqiao merged 3 commits intoPaddlePaddle:developfrom
jacquesqiao:use-word2vec
Sep 15, 2017
Merged

add save/load dict_and_embedding for word2vector#410
jacquesqiao merged 3 commits intoPaddlePaddle:developfrom
jacquesqiao:use-word2vec

Conversation

@jacquesqiao
Copy link
Member

No description provided.

@jacquesqiao jacquesqiao requested a review from reyoung September 15, 2017 22:01
f.write(key + " " + str(word_dict[key]) + "\n")
with open("embedding_table", "w") as f:
for line in embeddings:
f.write(",".join([str(x) for x in line]) + "\n")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

trainer.train(
paddle.batch(paddle.dataset.imikolov.train(word_dict, N), 32),
num_passes=100,
num_passes=1,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not change here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted

word_dict = dict()
with open("word_dict", "r") as f:
for line in f:
key, value = line.strip().split(" ")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe save in csv is a better idea, otherwise, the word cannot contain spaces.

It could be true since we could make some phrases as in our word dict.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, will do this later

Copy link
Collaborator

@reyoung reyoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little problem here. But do not break merge.

It can be fixed in another PR later.

@jacquesqiao jacquesqiao merged commit 37a6556 into PaddlePaddle:develop Sep 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants