Get Started

Model using two inputs and one output

Now that you have your two inputs (team id 1 and team id 2) and output (score difference), you can wrap them up in a model so you can use it later for fitting to data and evaluating on new data.

Your model will look like the following diagram:

This is a part of the course

“Advanced Deep Learning with Keras”

View Course

Exercise instructions

  • Define a model with the two teams as inputs and use the score difference as the output.
  • Compile the model with the 'adam' optimizer and 'mean_absolute_error' loss.

Hands-on interactive exercise

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

# Imports
from tensorflow.keras.layers import Subtract
from tensorflow.keras.models import Model

# Subtraction layer from previous exercise
score_diff = Subtract()([team_1_strength, team_2_strength])

# Create the model
model = ____([____, ____], ____)

# Compile the model
____(____, ____)
Edit and Run Code

This exercise is part of the course

Advanced Deep Learning with Keras

IntermediateSkill Level
4.7+
18 reviews

Learn how to develop deep learning models with Keras.

In this chapter, you will build two-input networks that use categorical embeddings to represent high-cardinality data, shared layers to specify re-usable building blocks, and merge layers to join multiple inputs to a single output. By the end of this chapter, you will have the foundational building blocks for designing neural networks with complex data flows.

Exercise 1: Category embeddingsExercise 2: Define team lookupExercise 3: Define team modelExercise 4: Shared layersExercise 5: Defining two inputsExercise 6: Lookup both inputs in the same modelExercise 7: Merge layersExercise 8: Output layer using shared layerExercise 9: Model using two inputs and one output
Exercise 10: Predict from your modelExercise 11: Fit the model to the regular season training dataExercise 12: Evaluate the model on the tournament test data

What is DataCamp?

Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.

Start Learning for Free