1. Fitting and Predicting with multiple inputs
Keras models with multiple inputs work just like Keras models with a single input.
They use the same fit, evaluate, and predict methods.
The only difference is that all of these methods take lists of inputs, rather a single input.
2. Fit with multiple inputs
To fit a model with multiple inputs, provide the model a list of inputs.
In this case, since you have two inputs, the model needs to have an input list of length 2.
You want to use this model to predict a single target, so the target for training is still a single object.
While this network is very simple, the concept it illustrates is quite advanced. Later in the course, you will process different inputs to the network in different ways.
In other words, multiple inputs let you do data pre-processing as part of the model you learn!
3. Predict with multiple inputs
To make predictions from a model with two inputs, you also need to provide two inputs to the model's predict() method, again as a list.
In this case, I've defined a model that adds numbers.
So in order to add 1 and 2, first convert 1 and 2 into 2D numpy arrays. Then pass 1 as the first input, and 2 as the second input.
The model outputs 3. Note that the data type of the output is float32.
You can also add other numbers with this simple model, e.g. 42 and 119.
Which add up to 161.
4. Evaluate with multiple inputs
To evaluate a model with multiple inputs, simply give it a list of inputs, along with a single output, and the model will return its loss on the new data.
In this case, since I've hard-coded the model to add the 2 inputs, the evaluation error on the test data is zero.
5. Let's practice!
Now that you know how to pass lists to models with multiple inputs, fit your multiple-input basketball model to some data.