def __init__(self, params):
     super(SequenceToSequence, self).__init__()
     self.embedding_matrix = load_word2vec(params)
     self.params = params
     self.encoder = rnn_encoder.Encoder(params["vocab_size"],
                                        params["embed_size"],
                                        params["enc_units"],
                                        params["batch_size"],
                                        self.embedding_matrix)
     self.attention = rnn_decoder.BahdanauAttention(params["attn_units"])
     self.decoder = rnn_decoder.Decoder(params["vocab_size"],
                                        params["embed_size"],
                                        params["dec_units"],
                                        params["batch_size"],
                                        self.embedding_matrix)
Пример #2
0
 def __init__(self, params):
     super(PGN, self).__init__()
     self.embedding_matrix = load_word2vec(
         params)  # 才开始涉及到向量:建立embedding表按自定义的字典来,如果没有则置全0
     self.params = params
     self.encoder = rnn_encoder.Encoder(params["vocab_size"],
                                        params["embed_size"],
                                        params["enc_units"],
                                        params["batch_size"],
                                        self.embedding_matrix)
     self.attention = rnn_decoder.BahdanauAttentionCoverage(
         params["attn_units"])
     self.decoder = rnn_decoder.Decoder(params["vocab_size"],
                                        params["embed_size"],
                                        params["dec_units"],
                                        params["batch_size"],
                                        self.embedding_matrix)
     self.pointer = rnn_decoder.Pointer()