tensorflow / skflow

Simplified interface for TensorFlow (mimicking Scikit Learn) for Deep Learning
Apache License 2.0
3.18k stars 439 forks source link

specifying sequence lengths #141

Closed mheilman closed 8 years ago

mheilman commented 8 years ago

Currently, it's not very clear how to use the sequence length functionality in TensorFlowRNNClassifier (link). This currently takes a tensor as an argument, since the argument is eventually passed along to tensorflow.nn.rnn, which expects an integer tensor. However, it's not clear how one would define that sequence length tensor since the input placeholder, from which one would compute it, is defined in the fit method using _setup_training.

It seems like maybe sequence_length should take a function whose input is the input placeholder and whose output is a tensor, rather than taking a tensor directly, similar to how the input_op_fn argument works.

If there is some way currently to use the sequence_length argument to specifying the sequence lengths for items in a minibatch, it'd be great to have an example using it. Currently, the examples don't use sequence lengths (example), which I think means that the RNN just reads in 0s at the ends of inputs that are padded up to the maximum sequence length.

mheilman commented 8 years ago

Here is what I was thinking with respect to the sequence length argument being a function.

terrytangyuan commented 8 years ago

Please consider submitting a PR to TensorFlow repo to fix this or add additional example. Thanks!