def __init__(self, weights_path=None,
vocab_path=None):
if weights_path is None:
weights_path = resource_filename(__name__,
'reactionrnn_weights.hdf5')
if vocab_path is None:
vocab_path = resource_filename(__name__,
'reactionrnn_vocab.json')
with open(vocab_path, 'r') as json_file:
self.vocab = json.load(json_file)
self.tokenizer = Tokenizer(filters='', char_level=True)
self.tokenizer.word_index = self.vocab
self.num_classes = len(self.vocab) + 1
self.model = reactionrnn_model(weights_path, self.num_classes)
self.model_enc = Model(inputs=self.model.input,
outputs=self.model.get_layer('rnn').output)
评论列表
文章目录