我收到此错误
KeyError:'sentence_embedding'
在线的:
rep = self.model(sentence_features[0])['sentence_embedding']
在 setence 转换器的 model.fit 函数中。
代码的更多部分:
train_data = ParallelSentencesDataset(student_model=student_model, teacher_model=teacher_model)
train_data.load_data('parallel5500TabTrain.tsv')
train_dataloader = DataLoader(train_data, shuffle=True, batch_size=train_batch_size)
train_loss = losses.MSELoss(model=student_model)
###### Load test sets ######
f = open("parallel5500TabTest.txt","r")
pairs = [line.strip().split("\t") for line in f]
f.close()
src = []
trg = []
for pair in pairs:
src.append(pair[0])
trg.append(pair[1])
evaluators = []
test_reader = ParallelSentencesDataset(student_model=model, teacher_model=teacher_model)
test_reader.load_data('parallel5500TabTest.tsv')
test_dataloader = DataLoader(test_reader, shuffle=False, batch_size=train_batch_size)
test_mse = evaluation.TranslationEvaluator(src, trg)
evaluators.append(test_mse)
###### Train model ######
output_path = "model-" + _datetime.date.today().strftime("%Y-%m-%d")
model.fit(train_objectives=[(train_dataloader, train_loss)],
evaluator=evaluators,
epochs=20,
evaluation_steps=1000,
warmup_steps=1000,
output_path=output_path
)
有谁知道它可能是什么?