I'm wondering how to make decoder in tensorflow rnn, feed it's i th output to (i+1)th input
my inputs have 20 sequence and 3680 dementions and my outputs have 39 sequence and 3680 dementions all data is 0~1 number
here is my model
with tf.variable_scope('encoder'):
enc_input = tf.placeholder(tf.float32,[None, input_sequence_length, input_dim])
enc_cell = tf.contrib.rnn.BasicLSTMCell(num_units = input_sequence_length)
_ , encoder_states = tf.nn.dynamic_rnn(enc_cell, enc_input , dtype=tf.float32)
with tf.variable_scope('decoder'):
dec_input = tf.placeholder(tf.float32,[None, output_sequence_length, output_dim])
dec_output = tf.placeholder(tf.float32,[None, output_sequence_length, output_dim])
dec_cell = tf.contrib.rnn.BasicLSTMCell(num_units = output_sequence_length)
outputs , _ = tf.nn.dynamic_rnn(dec_cell, dec_input,dtype = tf.float32,
initial_state = encoder_states)
how can i make decoder model that feed previous outputs to next input?
P.S
I make my self-answer code like this
with tf.variable_scope('decoder'):
dec_input = tf.placeholder(tf.float32,[None, 1, output_dim])
dec_output = tf.placeholder(tf.float32,[None, output_sequence_length, output_dim])
outputs = []
state = encoder_states
dec_cell = tf.contrib.rnn.BasicLSTMCell(num_units = dec_hidden_size)
for i in range(output_sequence_length):
if i==0:
output , state = tf.nn.dynamic_rnn(dec_cell, dec_input, initial_state = state, dtype = tf.float32)
outputs.append(output)
else:
output , state = tf.nn.dynamic_rnn(dec_cell,
output,
initial_state = state,
dtype = tf.float32)
outputs.append(output)
outputs = tf.reshape(outputs,[-1,output_dim])
outputs = tf.reshape(outputs,[-1,output_sequence_length,output_dim])
I think this code's output is different from upper code's output but I'm not sure it worked properly.
so still I wonder how to make decoder that has loop function((i)output->(i+1)input) with tensorflow method, because it takes more memory allocation than the upper code. (in my thought it has same cell count)