Session Ready
Exercise

Part 2: Understanding GRU models

You will now see how you can use Keras models to accept arbitrary sized batches of inputs. The ability to accept arbitrary sized batches is important for many reasons. For example, this allows you to define a single Keras model and experiment with different batch sizes during the model training stage, without having to change anything in the model.

For this exercise, keras and numpy (as np) have already been imported.

Instructions
100 XP
  • Define an input layer that accepts an arbitrary sized batch of data having sequence length 3 and input size 4.
  • Define a GRU layer with 10 hidden units that consumes the previous input and produces an output.
  • Define a Model called model that takes the input layer as the input and produces the output of the GRU layer as the output. Remember that you can use the keras.models.Model(<argument>=<value>) syntax to define a model.
  • Predict the model output for both x1 and x2.