nn.LSTM备忘
程序员文章站
2024-03-24 23:44:10
...
参考自:https://blog.csdn.net/m0_45478865/article/details/104455978
# (input_dim, output_dim, layers, )
lstm = nn.LSTM(768, 768, 1, bidirectional=True, batch_first=True)
# (batch_size, seq_len, hidden_size)
x = torch.randn(2, 512, 768)
result = lstm(x)
len(result) # 2 : (output, (hn, cn))
output, (hn, cn) = result
output.shape # torch.Size([2, 512, 1536])
hn.shape # hn代表最后一个单元,torch.Size([2, 2, 768])
cn.shape # torch.Size([2, 2, 768])
推荐阅读
-
nn.LSTM备忘
-
【PyTorch学习笔记】23:nn.LSTM和nn.LSTMCell的使用
-
pytorch nn.LSTM()参数详解
-
深度学习总结:tensorflow和pytorch关于RNN的对比,tf.nn.dynamic_rnn,nn.LSTM
-
nn.LSTM层出来的out和hn的关系
-
pytorch nn.LSTM()参数详解
-
pytorch中nn.Embedding和nn.LSTM和nn.Linear
-
eclipse中查看jdk的源码 博客分类: javajust do it备忘录more and morecommon java源码rt.jar
-
UML中类之间的几种关系:继承,实现,依赖,关联,聚合,组合的区别 博客分类: common备忘录more and morejust do itjava javauml类之间的几种关系区别
-
Oracle常见死锁发生的原因以及解决办法 博客分类: oracle备忘录 oracle死锁外键索引