There are two main types of models available in Keras: the Sequential model, and the tf.keras.Model
class. In this post, we will focus on the latter.
Model
is a class that can group layers into an object with training and inference features. There are two ways to instantiate a Model
:
1. With the basic “functional API”
We start from the input
, and chain layer calls to specify the model’s forward pass, and this model will include all layers required in the computation of outputs
given inputs
.
from keras.models import Model
from keras.layers import Input, Dense
inputs = Input(shape=(32,))
outputs = Dense(32)(inputs)
model = Model(inputs = inputs, outputs = outputs)
2. By subclassing the Model
class
We can also build