Tune Kim CNN for SST-2 and Improve SST-1 Results with Dataset/Initialization Changes (#133)

* SST change min_freq and Kim CNN init distribution

* Add tuned results for SST-1 and SST-2

* Fix typo
This commit is contained in:
Michael Tu
2018-07-11 22:08:26 -04:00
committed by GitHub
parent 5ff980d120
commit 82bf90f4bb
4 changed files with 69 additions and 18 deletions
+9 -9
View File
@@ -51,7 +51,7 @@ class SST1(TabularDataset):
train, val, test = cls.splits(path)
cls.TEXT_FIELD.build_vocab(train, val, test, min_freq=2, vectors=vectors)
cls.TEXT_FIELD.build_vocab(train, val, test, vectors=vectors)
return BucketIterator.splits((train, val, test), batch_size=batch_size, repeat=False, shuffle=shuffle,
sort_within_batch=True, device=device)
@@ -59,21 +59,21 @@ class SST1(TabularDataset):
class SST2(TabularDataset):
NAME = 'SST-2'
NUM_CLASSES = 5
TEXT_FIELD = Field(batch_first=True, tokenize=clean_str_sst)
LABEL_FIELD = Field(sequential=False, use_vocab=False, batch_first=True)
@staticmethod
def sort_key(ex):
return len(ex.text)
@classmethod
def splits(cls, path, train='stsa.binary.phrases.train', validation='stsa.binary.dev', test='stsa.binary.test', **kwargs):
return super(SST2, cls).splits(
path, train=train, validation=validation, test=test,
format='tsv', fields=[('label', cls.LABEL_FIELD), ('text', cls.TEXT_FIELD)]
)
@classmethod
def iters(cls, path, vectors_name, vectors_cache, batch_size=64, shuffle=True, device=0, vectors=None,
unk_init=torch.Tensor.zero_):
@@ -89,11 +89,11 @@ class SST2(TabularDataset):
"""
if vectors is None:
vectors = Vectors(name=vectors_name, cache=vectors_cache, unk_init=unk_init)
train, val, test = cls.splits(path)
cls.TEXT_FIELD.build_vocab(train, val, test, min_freq=2, vectors=vectors)
cls.TEXT_FIELD.build_vocab(train, val, test, vectors=vectors)
return BucketIterator.splits((train, val, test), batch_size=batch_size, repeat=False, shuffle=shuffle,
sort_within_batch=True, device=device)