A Sequential model can be created by passing a stack of layers to the constructor of a class called Sequential.
Creating a basic Sequential mode involves specifying one or more layers.
We will create a Sequential network with four layers.
- Layer 1 is a dense layer which has
input_shape
of (*, 784) and anoutput_shape
of (*, 32)
Note
A dense layer is a regular densely-connected neural network layer. A Dense layer implements the operation output = activation(dot(input, kernel) + bias), where activation is the element-wise activation
function passed as the activation
argument, kernel is a weights matrix created by the layer, and bias is a bias vector created by the layer. (This is only applicable if use_bias
is True
).
- Layer 2 is an activation layer with the
tanh
Activation
functionapplies activation to the incoming tensor:
keras.layers.Activation(activation)
Activation
can also be applied as a parameter to the dense layer:
model.add(Dense(64...