Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I feed last output y(t-1) as input for generating y(t) in tensorflow RNN?

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)

How can I feed last input y(t - 1) as input for updating the hidden state?

like image 940
Poorya Pzm Avatar asked Feb 02 '16 05:02

Poorya Pzm


People also ask

How does an RNN generate text?

The simplest way to generate text with this model is to run it in a loop, and keep track of the model's internal state as you execute it. Each time you call the model you pass in some text and an internal state. The model returns a prediction for the next character and its new state.

What is the output of a RNN?

Outputs and states A RNN layer can also return the entire sequence of outputs for each sample (one vector per timestep per sample), if you set return_sequences=True . The shape of this output is (batch_size, timesteps, units) .

What is LSTM Tensorflow?

Long short-term memory (LSTM) is an artificial recurrent neural network (RNN) architecture used in the field of deep learning. It was proposed in 1997 by Sepp Hochreiter and Jurgen schmidhuber. Unlike standard feed-forward neural networks, LSTM has feedback connections.


1 Answers

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])

Then call the RNN cell with processed_input and split there.

like image 159
Lukasz Kaiser Avatar answered Nov 08 '22 03:11

Lukasz Kaiser