def __init__(self,
options_file: str,
weight_file: str) -> None:
super(_ElmoCharacterEncoder, self).__init__()
with open(cached_path(options_file), 'r') as fin:
self._options = json.load(fin)
self._weight_file = weight_file
self.output_dim = self._options['lstm']['projection_dim']
self._load_weights()
# Cache the arrays for use in forward -- +1 due to masking.
self._beginning_of_sentence_characters = Variable(torch.from_numpy(
numpy.array(ELMoCharacterMapper.beginning_of_sentence_characters) + 1
))
self._end_of_sentence_characters = Variable(torch.from_numpy(
numpy.array(ELMoCharacterMapper.end_of_sentence_characters) + 1
))
评论列表
文章目录