July 2018
Beginner to intermediate
312 pages
8h 31m
English
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 ...
Read now
Unlock full access