Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better word vectors + charngram vectors #94

Merged
merged 4 commits into from
Aug 15, 2017
Merged

Conversation

bmccann
Copy link
Contributor

@bmccann bmccann commented Aug 15, 2017

No description provided.

@bmccann bmccann self-assigned this Aug 15, 2017
Copy link
Contributor

@jekbradbury jekbradbury left a comment

Choose a reason for hiding this comment

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

Looks good; make sure to flake8 though (also, I'll increment the version before merge because this is somewhat breaking and OpenNMT has already frozen the tag they use)

Remaining keyword arguments: Passed to the splits method.
"""
TEXT = data.Field()
LABEL = data.Field(sequential=False)

train, val, test = cls.splits(TEXT, LABEL, root=root, **kwargs)

TEXT.build_vocab(train, wv_dir=wv_dir, wv_type=wv_type, wv_dim=wv_dim)
TEXT.build_vocab(train, vectors=None)

This comment was marked as off-topic.

wv_type = v.split('.')[0]
wv_dim = int(v.split('.')[-1][:-1])
if wv_type == 'glove':
wv_name = '.'.join(v.split('.')[1:-1])

This comment was marked as off-topic.


def set_vectors(self, stoi, vectors, dim, unk_init='zero'):
self.vectors = torch.Tensor(len(self), dim)
self.vectors.normal_(0, 1) if unk_init == 'random' else self.vectors.zero_()

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

else:
vector = torch.Tensor(1, self.dim).zero_()
if self.unk_init == 'random':
vector.normal_(0, 1)

This comment was marked as off-topic.

@jekbradbury
Copy link
Contributor

jekbradbury commented Aug 15, 2017

I'm merging this, but we should be clear in 0.2 release notes about the two API changes this introduces: wv_type etc. being replaced by vectors (fairly straightforward) and the changes to word vector ordering and lookup, which won't affect most people but might be more subtle for anyone who relies on specifics of their current behavior.

@jekbradbury jekbradbury merged commit 56e32d0 into master Aug 15, 2017
@jekbradbury jekbradbury deleted the better_vectors branch September 7, 2017 22:42
@rachtsingh rachtsingh mentioned this pull request Nov 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants