Make an input layer for home vs. away
Now you will make an improvement to the model you used in the previous chapter for regular season games. You know there is a well-documented home-team advantage in basketball, so you will add a new input to your model to capture this effect.
This model will have three inputs: team_id_1
, team_id_2
, and home
. The team IDs will be integers that you look up in your team strength model from the previous chapter, and home will be a binary variable, 1 if team_1
is playing at home, 0 if they are not.
The team_strength_model
you used in the previous chapter has been loaded into your workspace. After applying it to each input, use a Concatenate layer to join the two team strengths and with the home vs away variable, and pass the result to a Dense layer.
This exercise is part of the course
Advanced Deep Learning with Keras
Exercise instructions
- Create three inputs layers of shape 1, one each for team 1, team 2, and home vs away.
- Lookup the team inputs in
team_strength_model()
. - Concatenate the team strengths with the home input and pass to a Dense layer.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create an Input for each team
team_in_1 = ____(shape=(1,), name='Team-1-In')
team_in_2 = ____(shape=(1,), name='Team-2-In')
# Create an input for home vs away
home_in = ____(shape=(1,), name='Home-In')
# Lookup the team inputs in the team strength model
team_1_strength = ____(____)
team_2_strength = ____(____)
# Combine the team strengths with the home input using a Concatenate layer, then add a Dense layer
out = _____()([____, ____, home_in])
out = _____(____)(____)