July 2019
Intermediate to advanced
512 pages
19h 39m
English
In a sequential model, we stack each layer, one above another:
from keras.models import Sequentialfrom keras.layers import Dense
First, let's define our model as a Sequential() model, as follows:
model = Sequential()
Now, define the first layer, as shown in the following code:
model.add(Dense(13, input_dim=7, activation='relu'))
In the preceding code, Dense implies a fully connected layer, input_dim implies the dimension of our input, and activation specifies the activation function that we use. We can stack up as many layers as we want, one above another.
Define the next layer with the relu activation, as follows:
model.add(Dense(7, activation='relu'))
Define the output layer with the sigmoid activations:
model ...Read now
Unlock full access