def __init__(self, n_enc_vocab, n_dec_vocab, n_hidden, bidirectional, linearTransform): super(Seq2SeqRNN_Attention, self).__init__() self.n_hidden = n_hidden self.num_directions = 2 if bidirectional is True else 1 self.encoder = nb.RNN(input_size=n_enc_vocab, hidden_size=n_hidden, bidirectional=bidirectional) self.decoder = nb.RNN(input_size=n_dec_vocab, hidden_size=n_hidden, bidirectional=bidirectional) self.attention = nb.AttentionTwo(n_dec_vocab, n_hidden, bidirectional=bidirectional, linearTransform=linearTransform)
def __init__(self, emb_dim, n_class, n_hidden, bidirectional=False, linearTransform=True): super(RNN_Attention, self).__init__() self.n_hidden = n_hidden self.num_directions = 2 if bidirectional is True else 1 self.rnn = nb.RNN(emb_dim, n_hidden, bidirectional=bidirectional) self.attention = nb.AttentionOne(n_class, n_hidden, bidirectional=bidirectional, linearTransform=linearTransform)