简体   繁体   English

具有多维输出目标的LSTM

[英]LSTMs with multi-dimensional output targets

Given a time series of 3D vectors, [x, y, z] where x, y, and z are arbitrary integers, I'd like to build a model that predicts the next vector in the series and captures patterns in each of the dimensions x, y, z. 给定3D矢量的时间序列, [x, y, z]其中x,y和z是任意整数,我想建立一个模型来预测系列中的下一个矢量并捕获每个维度中的模式x,y,z。

So if X = [[0, 0, 6], [1, 0, 0], [9, 9, 9], [3, 0, 3], [1, 2, 3]] and I give my model the 4-element sequence [[0, 0, 6], [1, 0, 0], [9, 9, 9], [3, 0, 3]] it would predict [1, 2, 3] 所以,如果X = [[0, 0, 6], [1, 0, 0], [9, 9, 9], [3, 0, 3], [1, 2, 3]] ,我给我的模型4元素序列[[0, 0, 6], [1, 0, 0], [9, 9, 9], [3, 0, 3]]预测[1, 2, 3]

I can't just one-hot encode each vector since the numbers can have arbitrary values, so I'm wondering how I can accomplish this. 我不能只对每个矢量进行一次热编码,因为数字可以有任意值,所以我想知道如何实现这一点。 Any insight is greatly appreciated, thank you! 非常感谢任何见解,谢谢!

Your input, in this case, is just the vector. 在这种情况下,您的输入只是矢量。 At timestep 1 the vector is [0,0,6] , at timestep 2 the vector is [1,0,0] , and so on. 在时间步1,矢量是[0,0,6] ,在时间步2,矢量是[1,0,0] ,依此类推。 For the output you are expected to pass the output through a fully connected layer that transforms it to the correct size for output. 对于输出,您应该通过完全连接的层传递输出,该层将其转换为正确的输出大小。

Assuming your sequence length is fixed you really don't have any preprocessing to do here, except perhaps standardizing or rescaling your inputs so they aren't very large numbers. 假设你的序列长度是固定的,你真的没有在这里进行任何预处理,除非标准化或重新调整你的输入,所以它们不是很大的数字。

In general, an RNN works a lot like a fully connected network. 通常,RNN的工作方式与完全连接的网络非常相似。 In fact an RNN cell is made up of 4 fully connected networks that are simply piped together in a non-trivial way. 实际上,RNN小区由4个完全连接的网络组成,这些网络简单地以非平凡的方式连接在一起。 But from the perspective of what you put in and what you get out, think of them like a simple fully connected network (per each timestep). 但是从你放入的内容和你得到的东西的角度来看,把它们想象成一个简单的完全连接的网络(每个时间步长)。

You can read up more on my last paragraph here: http://colah.github.io/posts/2015-08-Understanding-LSTMs/ 你可以在这里阅读我的最后一段更多内容: http//colah.github.io/posts/2015-08-Understanding-LSTMs/

If your sequence length is variable then you would typically add an input that flags it as the prediction step. 如果您的序列长度是可变的,那么您通常会添加一个输入,将其标记为预测步骤。 This could simply be all zero's such as: 这可能只是全部为零,例如:

X = [[0, 0, 6], [1, 0, 0], [9, 9, 9], [3, 0, 3], [0, 0, 0]]

or, if [0,0,0] is a valid datapoint you could add a feature to flag the timestep as an input or a prediction such as: 或者,如果[0,0,0]是一个有效的数据点,您可以添加一个特征来将时间步长标记为输入或预测,例如:

X = [[0, 0, 0, 6], [0, 1, 0, 0], [0, 9, 9, 9], [0, 3, 0, 3], [1, 0, 0, 0]]

Where the first value in that dataset indicates if the timestep is an input 0 or a prediction 1 . 其中该数据集中的第一个值指示时间步长是输入0还是预测1

You will have outputs at each timestep which you will ignore. 您将在每个时间步都有输出,您将忽略它们。 Your loss function will be based only on the output of the last timestep. 您的损失函数将仅基于最后一个时间步的输出。

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

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