没有合适的资源?快使用搜索试试~ 我知道了~
基于pytorch的lstm参数使用详解
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
![star](https://csdnimg.cn/release/downloadcmsfe/public/img/star.98a08eaa.png)
温馨提示
lstm(*input, **kwargs) 将多层长短时记忆(LSTM)神经网络应用于输入序列。 参数: input_size:输入’x’中预期特性的数量 hidden_size:隐藏状态’h’中的特性数量 num_layers:循环层的数量。例如,设置’ ‘ num_layers=2 ‘ ‘意味着将两个LSTM堆叠在一起,形成一个’堆叠的LSTM ‘,第二个LSTM接收第一个LSTM的输出并计算最终结果。默认值:1 bias:如果’ False’,则该层不使用偏置权重’ b_ih ‘和’ b_hh ‘。默认值:’True’ batch_first:如果’ ‘True ‘ ‘,则输入和输出张
资源详情
资源评论
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/14859433/bg1.jpg)
基于基于pytorch的的lstm参数使用详解参数使用详解
lstm(*input, **kwargs)
将多层长短时记忆将多层长短时记忆(LSTM)神经网络应用于输入序列。神经网络应用于输入序列。
参数:参数:
input_size:输入’x’中预期特性的数量
hidden_size:隐藏状态’h’中的特性数量
num_layers:循环层的数量。例如,设置’ ‘ num_layers=2 ‘ ‘意味着将两个LSTM堆叠在一起,形成一个’堆叠的LSTM ‘,第二个
LSTM接收第一个LSTM的输出并计算最终结果。默认值:1
bias:如果’ False’,则该层不使用偏置权重’ b_ih ‘和’ b_hh ‘。默认值:’True’
batch_first:如果’ ‘True ‘ ‘,则输入和输出张量作为(batch, seq, feature)提供。默认值: ‘False’
dropout:如果非零,则在除最后一层外的每个LSTM层的输出上引入一个“dropout”层,相当于:attr:’dropout’。默认值:0
bidirectional:如果‘True’,则成为双向LSTM。默认值:’False’
输入输入:input,,(h_0, c_0)
**input**of shape (seq_len, batch, input_size):包含输入序列特征的张量。输入也可以是一个压缩的可变长度序列。
see:func:’torch.nn.utils.rnn.pack_padded_sequence’ 或:func:’torch.nn.utils.rnn.pack_sequence’ 的细节。
**h_0** of shape (num_layers * num_directions, batch, hidden_size):张量包含批处理中每个元素的初始隐藏状态。
如果RNN是双向的,num_directions应该是2,否则应该是1。
**c_0** of shape (num_layers * num_directions, batch, hidden_size):张量包含批处理中每个元素的初始单元格状态。
如果没有提供’ (h_0, c_0) ‘,则**h_0**和**c_0**都默认为零。
输出输出:output,,(h_n, c_n)
**output**of shape (seq_len, batch, num_directions * hidden_size) :包含LSTM最后一层输出特征’ (h_t) ‘张量,
对于每个t. If a:class: ‘torch.nn.utils.rnn.PackedSequence’ 已经给出,输出也将是一个打包序列。
对于未打包的情况,可以使用’output.view(seq_len, batch, num_directions, hidden_size)’,正向和反向分别为方向’ 0 ‘和’ 1 ‘。
同样,在包装的情况下,方向可以分开。
**h_n** of shape (num_layers * num_directions, batch, hidden_size):包含’ t = seq_len ‘隐藏状态的张量。
与*output*类似, the layers可以使用以下命令分隔
h_n.view(num_layers, num_directions, batch, hidden_size) 对于’c_n’相似
**c_n** (num_layers * num_directions, batch, hidden_size):张量包含’ t = seq_len ‘的单元状态
所有的权重和偏差都初始化自: where:
include:: cudnn_persistent_rnn.rst
import torch
import torch.nn as nn
# 双向rnn例子
# rnn = nn.RNN(10, 20, 2)
# input = torch.randn(5, 3, 10)
# h0 = torch.randn(2, 3, 20)
# output, hn = rnn(input, h0)
# print(output.shape,hn.shape)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![py](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![h](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
weixin_38568031
- 粉丝: 5
- 资源: 895
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)
评论4