问题描述
我想在 Tensorflow 中设计一个单层 RNN,使得最后一个输出 (y(t-1))
参与更新隐藏状态.
I want to design a single layer RNN in Tensorflow such that last output (y(t-1))
is participated in updating the hidden state.
h(t) = tanh(W_{ih} * x(t) + W_{hh} * h(t) + **W_{oh}y(t - 1)**)
y(t) = W_{ho}*h(t)
如何将最后一个输入 y(t - 1)
作为更新隐藏状态的输入?
How can I feed last input y(t - 1)
as input for updating the hidden state?
推荐答案
y(t-1) 是最后的输入还是输出?在这两种情况下,它都不是与 TensorFlow RNN 单元抽象的直接契合.如果您的 RNN 很简单,您可以自己编写循环,然后您就可以完全控制.我会使用的另一种方法是预处理您的 RNN 输入,例如,执行以下操作:
Is y(t-1) the last input or output? In both cases it is not a straight fit with the TensorFlow RNN cell abstraction. If your RNN is simple you can just write the loop on your own, then you have full control. Another way that I would use is to pre-process your RNN input, e.g., do something like:
processed_input[t] = tf.concat(input[t], input[t-1])
然后使用processed_input调用RNN单元并在那里拆分.
Then call the RNN cell with processed_input and split there.
这篇关于如何将最后一个输出 y(t-1) 作为输入以在 tensorflow RNN 中生成 y(t)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!