我想提供时间序列数据 - 一次一步,以增量构建 rnn(经过几个初始步骤)。
目前 rnn() 将 encoder_input 和 decoder_input 作为完整序列。
def rnn_seq2seq(encoder_inputs, decoder_inputs, cell, initial_state=None,output_projection=None,feed_previous=False, dtype=tf.float32, scope=None):
with tf.variable_scope(scope or "rnn_seq2seq"):
_, enc_states = rnn.rnn(cell, encoder_inputs, initial_state=initial_state, dtype=dtype)
def extract_argmax(prev, i):
with tf.device('/gpu:0'):
prev = tf.nn.softmax(tf.nn.xw_plus_b(prev, output_projection[0], output_projection[1]))
return prev
loop_function = None
if feed_previous:
loop_function = extract_argmax
print enc_states[-1]
return seq2seq.rnn_decoder(decoder_inputs, enc_states[-1], cell, loop_function=loop_function)
feedP = tf.placeholder(dtype=tf.bool)
with tf.variable_scope("mylstm"):
output,state = rnn_seq2seq(enc_inputs,dec_inputs,cell,output_projection=output_projection,feed_previous=feedP)
是否可以一次输入decoder_input 而不是整个序列,因为这就是数据实时出现的方式?