To change the LSTM example in the last section to the GRU network, change the cell type as follows and the TensorFlow takes care of the rest for you:
cell = tf.nn.rnn_cell.GRUCell(state_size)
The complete code for the GRU model is provided in the notebook ch-07a_RNN_TimeSeries_TensorFlow.
For the small airpass dataset, the GRU has shown better performance for the same number of epochs. In practice, GRU and LSTM have shown comparable performance. In terms of execution speed, the GRU model trains and predicts faster as compared to the LSTM.
The complete code for the GRU model is provided in the Jupyter notebook. The results from the GRU model are as follows:
train mse = 0.0019633215852081776 test mse = 0.014307591132819653 test rmse = 0.11961434334066987
We encourage you to explore other options available in TensorFlow to create recurrent neural networks. Now...