1. Learn
  2. /
  3. Courses
  4. /
  5. Machine Translation with Keras

Connected

Exercise

Part 1: Enter to win amazing prizes

In this exercise, you will learn about the Dense layer. Why not do that with a fun exercise? Imagine there's a game show where prizes are determined by a neural network. The contestant enters

  • the number of siblings,
  • the number of coffees had today and
  • if they like tomatoes or not,

and the model predicts what the contestant will win.

To implement this, you will be using Keras. You will need to create a model with an input layer which accepts three features (the number of siblings as an integer, the number of coffees as an integer and if they like tomatoes or not as a 0 or 1). Then the input goes through a Dense layer which outputs 3 probabilities (i.e. probabilities of winning a car, a gift voucher or nothing).

Input and Dense layers as well as a Model object from Keras are already imported. You are also provided a weight initializer called init to initialize the Dense layer.

Instructions

100 XP
  • Define an input layer which only accepts 3 contestants (batch size), where each contestant has 3 inputs: sibling count, number of coffees and tomato preference (input size).
  • Define a Dense layer which has 3 outputs, softmax activation and init as the initializer.
  • Compute the model predictions for x using the defined model.
  • Get the most probable prize (as an integer) for each contestant.