Using the Keras Subclassing API
Keras is based on object-oriented design principles. So, we can subclass the Model
class and create our model architecture definition.
The Keras Subclassing API is the third way proposed by Keras to build deep neural network models.
This API is fully customizable, but this flexibility also brings complexity! So, hold on to your hats, it's harder to use than the Sequential or Functional API.
But you're probably wondering why we need this API if it's so hard to use. Some model architectures and some custom layers can be extremely challenging. Some researchers and some developers hope to have full control of their models and the way to train them. The Subclassing API provides these features. Let's go into the details.
Getting ready
Here, we will cover the main ways of creating a custom layer and a custom model using the Keras Subclassing API.
To start, we load TensorFlow, as follows:
import tensorflow as...