I’m very sorry to post such question, the solution is quite easy:
out: output tensor with shape (sequence_length, batch_size, num_hidden) when layout is “TNC”. If bidirectional is True, output shape will instead be (sequence_length, batch_size, 2*num_hidden) out_states: a list of two output recurrent state tensors with the same shape as in states. If states is None out_states will not be returned.
I try to implement torch-rnn by using MXNet, but I find there are no “remember state” nor “reset” function I could use when using gluon:
if a “remember state” param is possible,the program will be very easy to write:
with self.net.name_scope(): self.net.add(nn.Embedding(V,D)) for i in range(self.num_layers): prev_dim = H if i > 1 else D if self.model_type == 'rnn' : rnn = rnn.GRU(prev_dim, H,dropout=self.dropout) elif self.model_type == 'lstm' : rnn = rnn.LSTM(prev_dim, H,dropout=self.dropout) else : rnn = rnn.RNN(prev_dim, H,dropout=self.dropout) if self.batchnorm == 1 : self.net.add(nn.BatchNorm()) self.net.add(nn.Dense(H,V))
But I do not know how to using that paraments(as far as i know, such paraments does not exist.) It seems that the only solution is using mx.sym, unroll LSTM manually, and manually reset the states of LSTM.
But I wonder are there some easy solutions?