mirror of
https://github.com/wassname/Castor.git
synced 2026-09-12 12:02:24 +08:00
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:
+9
-9
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user