2

I want to feed timeseries data as it comes - one step at a time, to incrementally build the rnn ( after few initial steps ).

currently the rnn() takes encoder_input and decoder_input as complete sequence.

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)

Is it possible to feed decoder_input one step at a time instead of whole sequence, because that's how the data would come in real time ?

Guy Coder
  • 24,501
  • 8
  • 71
  • 136

1 Answers1

0

Check out Scikit Flow. The example folder includes a lot of examples dealing with RNNs and there are built-in RNN estimators that you can just plug into your existing code.

Check this fit() method in estimators and you'll find partial_fit() that allows continuous training, which suits your needs. Many of the examples use this to continue training in a while loop and save the checkpoint over time (you can also configure the frequency).

Hope this helps.

Yuan Tang
  • 696
  • 4
  • 15
  • partial_fit simply calls fit() function without adding any value. How is this going to help at all ? you would need to specify the model for RNN in skflow. what would the model look like in this case ? – Sameer Kumar Feb 19 '16 at 06:31
  • It's actually the same as fit since fit is implemented in a way that accepts iterator or can take one sample at a time. It's just for a better API for users. The examples might help you get started, e.g. seq2seq, RNN/LSTM, etc. Hope this helps. – Yuan Tang Feb 19 '16 at 13:15