输入和输出到Pytorch中的LSTMS
我想在Pytorch中实现LSTM,因为我的数据是时间序列数据,即视频框架以进行心率检测,我正在为LSTMS的输入和输出尺寸而苦苦挣扎。在考虑时间步骤,隐藏状态等时,在Pytorch中LSTMS的输入非常令人困惑 我来自CNN的输出是“ 2批256帧”,现在是LSTMS的输入 批次是2 功能= 256 输出也是256帧的2批次。
I want to implement lstms with CNN in pytorch as my data is a time series data i.e. frames of video for heart rate detection, I am struggling with the input and output dimensions for lstms what and how i should properly configure the dimensions/parameters/arguments at input of lstms in pytorch as its quite confusing when considering time steps, hidden state etc.
my output from CNN is “2 batches of 256 frames”, which is now the input to lstms
batch is 2
features =256
the output is also a batch of 2 with 256 frames.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,顺序数据的输入形状采用
(batch_size, seq_len, num_features)
的形式。根据您的解释,我假设您的输入格式为(2, 256)
,其中 2 是批量大小,256 是标量(一维张量)的序列长度。因此,您应该通过inputs.unsqueeze(2)
将输入重塑为(2, 256, 1)
。要声明和使用 LSTM 模型,只需尝试
Generally, the input shape of sequential data takes the form
(batch_size, seq_len, num_features)
. Based on your explanation, I assume your input is of the form(2, 256)
, where 2 is the batch size and 256 is the sequence length of scalars (1-dimensional tensor). Therefore, you should reshape your input to be(2, 256, 1)
byinputs.unsqueeze(2)
.To declare and use an LSTM model, simply try