def feed_dict(self, dataset: Dataset, train: bool = False) -> FeedDict:
sentences = cast(Iterable[List[str]],
dataset.get_series(self.data_id, allow_none=True))
sentences_list = list(sentences) if sentences is not None else None
fd = {} # type: FeedDict
if sentences is not None:
label_tensors, _ = self.vocabulary.sentences_to_tensor(
sentences_list, self.max_output_len)
# pylint: disable=unsubscriptable-object
fd[self.gt_inputs[0]] = label_tensors[0]
# pylint: enable=unsubscriptable-object
fd[self.train_mode] = train
return fd
评论列表
文章目录