Aan de slagGa gratis aan de slag

Understanding sequential model output

In this exercise you will learn to use the keras.layers.GRU layer. keras.layers.GRU nicely wraps the functionality of a GRU to a Layer object.

You will explore what the shape of the output of a GRU layer looks like and how it changes when different arguments are provided. It is rare to view the numerical vectors produced by a GRU in real life, but in order to use these layers in more complex models, you need to have a good understanding of the shapes of the outputs and how to get the desired output using various arguments.

Here you will have keras, and numpy (as np) loaded already. You can access layers by calling keras.layers.<Layer> or a model by calling keras.models.Model.

Deze oefening maakt deel uit van de cursus

Machine Translation with Keras

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Define the Input layer
inp = keras.layers.____(batch_shape=(____,____,5))
# Define a GRU layer that takes in inp as the input
gru_out1 = keras.layers.____(____)(____)
print("gru_out1.shape = ", gru_out1.____)
Code bewerken en uitvoeren