Input

As we are looking at providing input dynamically, we will use TensorFlow's placeholder for our input. As we have a definite shape for the data, in terms of batch size and the number of words we can process per batch, we need to first pad the sentences in our dataset, to make them of the same length. Hence, we will define two placeholders, as follows:

# Define input placeholder for the word indices of shape = (batch size, length of padded sentence)
word_indices = tf.placeholder(tf.int32, shape=[None, None])

# Placeholder for the sequence lengths of shape = (batch size)
sequence_lengths = tf.placeholder(tf.int32, shape=[None])

The sequence length placeholder allows the computation graph to utilize the actual length of the input data, as we padded the initial input to make it all of the same max_length

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset