- Elman RNN
- Jordan RNN
- Bidirectional RNN
- LSTM - Cell
LSTM:
理解Pytorch中的LSTM (refer:https://www.cnblogs.com/marsggbo/p/12123755.html)
lstm=nn.LSTM(input_size=300,hidden_size=128,num_layers=2)
input=torch.rand([10,64,300]) #seq_len, batch, input_size
h0=torch.rand([2,64,128]) # num_layes * direction_numbers,batch,hidden_size
c0=torch.rand([2,64,128]) # num_layes * direction_numbers,batch,hidden_size
c
output,(hn,cn)=lstm(input,(h0,c0))
print(output.shape) # seq_len,batch,hidden_size
print(hn.shape) # num_layes * direction_numbers,batch,hidden_size
print(cn.shape) # num_layes * direction_numbers,batch,hidden_size
'''
torch.Size([10, 64, 128])
torch.Size([2, 64, 128])
torch.Size([2, 64, 128])
'''