Question about seq2seq tutorial

Hi everone,

I’m new to pytorch. When I try to understand code from, I don’t understand why encoder or decoder need resize input tensor, look the code:

class EncoderRNN(nn.Module):
    def __init__(self, input_size, hidden_size, n_layers=1):
        super(EncoderRNN, self).__init__()
        self.n_layers = n_layers
        self.hidden_size = hidden_size
        self.embedding = nn.Embedding(input_size, hidden_size)
        self.gru = nn.GRU(hidden_size, hidden_size)

def forward(self, input, hidden):
    embedded = self.embedding(input).view(1, 1, -1)
    output = embedded
    for i in range(self.n_layers):
        output, hidden = self.gru(output, hidden)
    return output, hidden

def initHidden(self):
    result = Variable(torch.zeros(1, 1, self.hidden_size))
    if use_cuda:
        return result.cuda()
        return result

above the code, input tensor after embedding be resize to (1,1,-1)(embedded = self.embedding(input).view(1, 1, -1)), why can’t use origin dim (seq_len, batch_size, feature_size). plz help.