(self, vocab_size, embedding_size,
                 hidden_size, rnn=nn.GRU, num_layers=1, bidirectional=False,
                 dropout=0.0, bias=True, batch_first=True)
Sentence-level Encoder
Sentence-level Encoder
Sentence - level Encoder
def __init__(self, vocab_size, embedding_size,
                 hidden_size, rnn=nn.GRU, num_layers=1, bidirectional=False,
                 dropout=0.0, bias=True, batch_first=True):
        """Sentence-level Encoder"""
        super(EncoderRNN, self).__init__()

        self.vocab_size = vocab_size
        self.embedding_size = embedding_size
        self.hidden_size = hidden_size
        self.num_layers = num_layers
        self.dropout = dropout
        self.batch_first = batch_first
        self.bidirectional = bidirectional

        if bidirectional:
            self.num_directions = 2
        else:
            self.num_directions = 1

        # word embedding
        self.embedding = nn.Embedding(vocab_size, embedding_size, padding_idx=PAD_ID)

        self.rnn = rnn(input_size=embedding_size,
                        hidden_size=hidden_size,
                        num_layers=num_layers,
                        bias=bias,
                        batch_first=batch_first,
                        dropout=dropout,
                        bidirectional=bidirectional)
def __init__ ( self , vocab_size , embedding_size , hidden_size , rnn = nn . GRU , num_layers = 1 , bidirectional = False , dropout = 0.0 , bias = True , batch_first = True ) : super ( EncoderRNN , self ) . __init__ ( ) self . vocab_size = vocab_size self . embedding_size = embedding_size self . hidden_size = hidden_size self . num_layers = num_layers self . dropout = dropout self . batch_first = batch_first self . bidirectional = bidirectional if bidirectional : self . num_directions = 2 else : self . num_directions = 1 # word embedding self . embedding = nn . Embedding ( vocab_size , embedding_size , padding_idx = PAD_ID ) self . rnn = rnn ( input_size = embedding_size , hidden_size = hidden_size , num_layers = num_layers , bias = bias , batch_first = batch_first , dropout = dropout , bidirectional = bidirectional )