Now that the model has been trained, we can have some fun with it. In this section, we will see how we can use the model to generate book scripts. Use the following parameters:
- Script Length = 200 words
- Starting word =Â postgresql
Follow these steps to generate the model:
- Load the graph of the trained model.
- Extract four tensors, as follows:
- Input/input:0
- Network/initial_state:0
- Network/final_state:0
- Network/probs:0
Extract the four tensors using the following code:
def extract_tensors(tf_graph):
"""
Get input, initial state, final state, and probabilities tensor from the graph
:param loaded_graph: TensorFlow graph loaded from file
:return: Tuple (tensor_input,tensor_initial_state,tensor_final_state, tensor_probs)
"""
tensor_input = tf_graph.get_tensor_by_name("Input/input:0")
tensor_initial_state = tf_graph...