-
Notifications
You must be signed in to change notification settings - Fork 811
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
Conversation
There was a problem hiding this 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)
torchtext/datasets/sentiment.py
Outdated
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.
This comment was marked as off-topic.
Sorry, something went wrong.
torchtext/vocab.py
Outdated
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.
This comment was marked as off-topic.
Sorry, something went wrong.
torchtext/vocab.py
Outdated
|
||
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.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torchtext/vocab.py
Outdated
else: | ||
vector = torch.Tensor(1, self.dim).zero_() | ||
if self.unk_init == 'random': | ||
vector.normal_(0, 1) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
e0b27fc
to
e876d55
Compare
I'm merging this, but we should be clear in 0.2 release notes about the two API changes this introduces: |
No description provided.