Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing RNN state to next batch in customer estimator? #353

Closed
SinanGabel opened this issue Dec 27, 2018 · 1 comment
Closed

Passing RNN state to next batch in customer estimator? #353

SinanGabel opened this issue Dec 27, 2018 · 1 comment

Comments

@SinanGabel
Copy link

source: https://github.com/GoogleCloudPlatform/training-data-analyst/blob/master/courses/machine_learning/deepdive/05_artandscience/d_customestimator.ipynb

In model code "simple_rnn" the state is not passed on to the next batch (if I understand it correctly):

   outputs, _ = rnn.static_rnn(lstm_cell, x, dtype = tf.float32)

However if we had a very long time series (SEQ_LEN large e.g. 10000) that we would want to split up into smaller chunks how could we pass on the state to the next batch (i.e. rather than starting from a zero state each time)?

   # initialize somewhere
   state = tf.zeros([BATCH_SIZE, LSTM_SIZE], dtype=tf.float32)  

   # in model code
   outputs, state = rnn.static_rnn(lstm_cell, x, initial_state=state, dtype=tf.float32)

   # the outputs are passed on and used to produce the "predictions_dict"

QUESTION: where & how do we initialize the state, and how is the state passed on when creating a customer estimator?

@lakshmanok
Copy link
Contributor

The simple_rnn illustrates the case where you have multiple independent short sequences.

For training on a single long sequence, look at the temperatures notebook in Course 9 (which is on sequences):

https://github.com/GoogleCloudPlatform/training-data-analyst/blob/master/courses/machine_learning/deepdive/09_sequence/temperatures.ipynb

This was referenced Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants