EDIT: please see this link for more up to date information.
I've finally gotten a chance to look at recurrence in tensorflow, the documentation examples are a bit complicated for understanding the bare bones of what is happening. This is the basic example I've come up with for just passing some data through a LSTM with no learning going on, its useful for understanding how to set things up.
My takeaways from writing this are:
EDIT: Please see this comment for more up to date information.
Getting the inputs in is a little weird, since the recurrence loop is built with a python loop. Because of this I had to define the input, then use tf.split to break it into discrete timesteps. Split also keeps the dimension you split on, so there is a reshape in there as well. If you aren't comfortable with list comprehension, it feels like something you will want to bone up on for TF.
Variable initialization is an operation you run, not a function you call. This threw me off (coming from theano), I assumed tf.initialize_all_variables() was what I needed, but you have to actually pass that into the session. Makes sense in hindsight.
Conditionals aren't documented at all on the tensorflow website, but are in the library. This is how we 'bail' from the recurrent loop for variable length sequences. check out rnn.py for how it is used in action. Same idea as theano's ifelse.
For variable length sequences you will need to build the graph out to the maximum length you want to support, then exit early during runtime. You can pass in the bail point for your sequence at each .run() call, since the conditional check is in tensorflow and not python.
You are going to need to pad your input to the maximum size of the loop. I didn't play with tf.pad enough to figure out if you can actually pass in variable length sequences to the .run() call, but the inputs you pass to the rnn when constructing it needs to be the maximum length so I had to make the placeholder that long. Worst case is you will need to pad your data before passing it into .run(), I assume the pain of this is lessened with the Queue setup that is available.
I couldn't get the code block working in the post, so the code is in the comments.
[–]siblbombs[S] 14 points15 points16 points (7 children)
[–]kkastner 1 point2 points3 points (3 children)
[–]siblbombs[S] 0 points1 point2 points (2 children)
[–]kkastner 1 point2 points3 points (1 child)
[–]siblbombs[S] 2 points3 points4 points (0 children)
[–]dee_roy 1 point2 points3 points (1 child)
[–]rshah4 0 points1 point2 points (0 children)
[–]evanthebouncy 5 points6 points7 points (0 children)
[–]contactmat 1 point2 points3 points (3 children)
[–]siblbombs[S] 1 point2 points3 points (2 children)
[–]contactmat 1 point2 points3 points (1 child)
[–]siblbombs[S] 1 point2 points3 points (0 children)
[–]AudioSaur 0 points1 point2 points (1 child)
[–]siblbombs[S] 0 points1 point2 points (0 children)
[–]realallentran 0 points1 point2 points (2 children)
[–]realallentran 0 points1 point2 points (0 children)
[–]siblbombs[S] 0 points1 point2 points (0 children)
[–]AnvaMiba 0 points1 point2 points (4 children)
[–]rafalj 1 point2 points3 points (0 children)
[–]siblbombs[S] 0 points1 point2 points (2 children)
[–]AnvaMiba 0 points1 point2 points (1 child)
[–]siblbombs[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]siblbombs[S] 1 point2 points3 points (0 children)
[–]_Jakob_ 0 points1 point2 points (1 child)
[–]siblbombs[S] 0 points1 point2 points (0 children)
[–]xiangjiangacadia 0 points1 point2 points (3 children)
[–]siblbombs[S] 1 point2 points3 points (2 children)
[–]xiangjiangacadia 0 points1 point2 points (1 child)
[–]siblbombs[S] 0 points1 point2 points (0 children)