Using the TensorFlow RNN API
We will now examine how we can use the TensorFlow RNN API to make the code simpler. The TensorFlow RNN API contains a variety of RNN-related functions that help us to implement RNNs faster and easier. We will now see how the same example we discussed in the preceding sections can be implemented using the TensorFlow RNN API. However, to make things exciting, we will implement a deep LSTM network with three layers that we talked about in the comparisons. The full code for this is available in the lstm_word2vec_rnn_api.ipynb
file in the Ch8
folder.
First, we will define the placeholders for holding inputs, labels, and corresponding embedding vectors for the inputs. We ignore the validation data related computations as we have already discussed them:
# Training Input data. train_inputs, train_labels = [],[] train_labels_ohe = [] # Defining unrolled training inputs for ui in range(num_unrollings): train_inputs.append(tf.placeholder(tf.int32, shape=[batch_size...