转:PyTorch中LSTM的输入输出格式

参考一:

PyTorch中LSTM的输出格式

该文章的核心内容截图如下:

总的结论

注意:如果在搭建lstm网络时使用了batch_first=True,则lstm网络不仅接受的数据第一维是batch,而且输出的结果中,batch也会在第一维,即

  • output's shape (batch, seq_len, hidden_size * num_direction)
  • h_n's shape (batch, num_layers * num_directions, hidden_size)
  • c_n's shape (batch, num_layers * num_directions, hidden_size)

参考二:

理解Pytorch中LSTM的输入输出参数含义

该文章的主要内容如下:

原文地址:https://www.cnblogs.com/picassooo/p/13470992.html