Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions instructor/real_data/instructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def __init__(self, opt):
try:
self.train_data = GenDataIter(cfg.train_data)
self.test_data = GenDataIter(cfg.test_data, if_test_data=True)
except:
pass
except Exception as e:
print(f'Could not load train and test data: {e}')

try:
self.train_data_list = [GenDataIter(cfg.cat_train_data.format(i)) for i in range(cfg.k_label)]
Expand All @@ -52,8 +52,8 @@ def __init__(self, opt):

self.train_samples_list = [self.train_data_list[i].target for i in range(cfg.k_label)]
self.clas_samples_list = [self.clas_data_list[i].target for i in range(cfg.k_label)]
except:
pass
except Exception as e:
print(f'Could not create train_samples_list and class_samples_list: {e}')

# Criterion
self.mle_criterion = nn.NLLLoss()
Expand Down
1 change: 1 addition & 0 deletions utils/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def prepare(samples, gpu=False):
def load_data(self, filename):
"""Load real data from local file"""
self.tokens = get_tokenlized(filename)
self.tokens = [tokens for tokens in self.tokens if len(tokens) > 0]
samples_index = tokens_to_tensor(self.tokens, self.word2idx_dict)
return self.prepare(samples_index)

Expand Down