简体   繁体   English

我想知道在这种情况下如何将参数放在 nn.LSTM 中

[英]I wonder how to put the parameters in nn.LSTM in this situation

I want to say that I'm not familiar with English.我想说我不熟悉英语。

Hi, I'm recently building LSTM Layers using nn.LSTM .嗨,我最近正在使用nn.LSTM构建 LSTM 层。

What I want to do is predicting next 48 values using 48*7=336 sequential inputs.我想要做的是使用 48*7=336 顺序输入来预测接下来的 48 个值。
And here is preprocessed dataframe will be used.这里将使用经过预处理的 dataframe。 It has 384 cols(=336+48) and 457068 rows(=929x492).它有 384 列(=336+48)和 457068 行(=929x492)。
In short, there are 929 customers and each customers has 492 sequential data with a length of 384(=336+48)简而言之,有929个客户,每个客户有492个序列数据,长度为384(=336+48)

customerID客户ID col1 col1 col2 col2 ... ... col380 col380
1 1 data_{1,1}数据_{1,1} data_{1,2}数据_{1,2} ... ... data_{1,380}数据_{1,380}
1 1 data_{2,1}数据_{2,1} data_{2,2}数据_{2,2} ... ... data_{2,380}数据_{2,380}
... ... ... ... ... ... ... ... ... ...
1 1 data_{492,1}数据_{492,1} data_{492,2}数据_{492,2} ... ... data_{492,380}数据_{492,380}
2 2 data_{493,1}数据_{493,1} data_{493,2}数据_{493,2} ... ... data_{493,380}数据_{493,380}
... ... ... ... ... ... ... ... ... ...
929 929 data_{4670687,1}数据_{4670687,1} data_{4670687,2}数据_{4670687,2} ... ... data_{4670687,380}数据_{4670687,380}
929 929 data_{4670688,1}数据_{4670688,1} data_{4670688,2}数据_{4670688,2} ... ... data_{4670688,380}数据_{4670688,380}

Here, 3 parameters for nn.LSTM: (input_size, hidden_size, num_layers)这里,nn.LSTM 的 3 个参数:(input_size, hidden_size, num_layers)
Also Input tensor has 3 dimensions: (seq_len, batch, input_size)\输入张量也有 3 个维度:(seq_len, batch, input_size)\

In this situation, please let me know how to enter the above parameters.在这种情况下,请告诉我如何输入上述参数。 I will use num_layers=2 .我将使用num_layers=2
Thank You.谢谢你。

Well, in the 3 parameters for the LSTM, input_size will be the same as input_size in your input tensor, which here is 336 .好吧,在 LSTM 的 3 个参数中, input_size将与输入张量中的 input_size 相同,这里是336

hidden_size could be any number you want, it is basically the number of nodes or features you want to learn. hidden_size可以是你想要的任何数字,它基本上是你想要学习的节点或特征的数量。 The higher the number the more the model learns about your data at each training iteration.数字越高,model 在每次训练迭代中了解您的数据就越多。 It mostly depends on how tough your task is for your model, though you would not want this to be unnecessarily large.这主要取决于您的任务对 model 的难度,尽管您不希望它变得不必要地大。

Since you have chosen num_layers=2 you can define the LSTM like this:由于您选择num_layers=2 ,您可以像这样定义 LSTM:

# Using hidden_size=256, which could be any number you want
nn.LSTM(input_size=336, hidden_size=256, num_layers=2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM