Get startedGet started for free

Define team model

The team strength lookup has three components: an input, an embedding layer, and a flatten layer that creates the output.

If you wrap these three layers in a model with an input and output, you can re-use that stack of three layers at multiple places.

Note again that the weights for all three layers will be shared everywhere we use them.

This exercise is part of the course

Advanced Deep Learning with Keras

View Course

Exercise instructions

  • Create a 1D input layer for the team ID (which will be an integer). Be sure to set the correct input shape!
  • Pass this input to the team strength lookup layer you created previously.
  • Flatten the output of the team strength lookup.
  • Create a model that uses the 1D input as input and flattened team strength as output.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Imports
from tensorflow.keras.layers import Input, Embedding, Flatten
from tensorflow.keras.models import Model

# Create an input layer for the team ID
teamid_in = ____(shape=(____,))

# Lookup the input in the team strength embedding layer
strength_lookup = team_lookup(____)

# Flatten the output
strength_lookup_flat = Flatten()(____)

# Combine the operations into a single, re-usable model
team_strength_model = ____(____, ____, name='Team-Strength-Model')
Edit and Run Code