1. Three-input models
In this chapter, you'll extend your two input model to three inputs, and beyond.
This demonstrates the power of the Keras functional API. Once you have learned how to work with two input networks, it is trivial to extend that knowledge to 3 or more input networks.
2. Simple model with 3 inputs
Making a keras model with 3 inputs is almost exactly the same as making a Keras model with two inputs.
To start, create three different input layers.
In this case, you'll use a Concatenate layer to combine the inputs, but recall from the previous chapters that you could also use an Add or Subtract layer.
In the concatenate layer, simply pass a list of three inputs, rather than two.
Finally, add a Dense layer to reduce the three inputs to a single output.
3. Simple model with 3 inputs
When creating a model with three inputs, simply pass a list with three input layers and one output layer.
4. Shared layers with 3 inputs
In the exercises for this chapter, you will also practice using a shared layer in a model with more than two inputs.
For example, you can pass the first two inputs to a shared layer and then concatenate the result of that shared layer with the third input.
In other words, you can define a Keras model in any way you want! This gives you a lot of flexibility to customize the model to the problem you want to solve.
5. Shared layers with 3 inputs
As before, we pass the original three inputs to the Model() function when creating a model.
6. Fitting a 3 input model
As with any Keras model, you must compile it before fitting. During compilation, you specify a loss function and an optimizer.
When fitting a three input model, provide a list with three input columns, rather than two.
Since this model only has one output, use a single output in your model.
Similarly, when evaluating your model on new data, using model.evaluate(), pass three inputs in a list and one output.
7. Let's practice
It's time for you to fit three-input models. Once you understand how easy it is to extend two input models to three inputs, you should also be able to make models with four inputs, or five, or more!