Creating the Keras model
The Keras model can be created using the sequential API or functional API. The examples of creating models in both ways are given in the following subsections.
Sequential API for creating the Keras model
In the sequential API, create the empty model with the following code:
model = Sequential()
You can now add the layers to this model, which we will see in the next section.
Alternatively, you can also pass all the layers as a list to the constructor. As an example, we add four layers by passing them to the constructor using the following code:
model = Sequential([ Dense(10, input_shape=(256,)), Activation('tanh'), Dense(10), Activation('softmax') ])
Functional API for creating the Keras model
In the functional API, you create the model as an instance of the Model
class that takes an input and output parameter. The input and output parameters represent one or more input and output tensors, respectively...