2

我想提供时间序列数据 - 一次一步,以增量构建 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 而不是整个序列,因为这就是数据实时出现的方式?

4

1 回答 1

0

查看Scikit 流。示例文件夹包含许多处理 RNN 的示例,并且有内置的 RNN 估计器,您可以将其插入现有代码中。

在估算器中检查此fit()方法,您会发现partial_fit()它允许持​​续训练,这适合您的需求。许多示例使用它来继续while循环训练并随着时间的推移保存检查点(您也可以配置频率)。

希望这可以帮助。

于 2016-02-18T01:36:06.697 回答