September 2018
Intermediate to advanced
412 pages
11h 12m
English
The following sections depict the steps for building a neural network using the Keras framework.
The step for creating a sequential model is as follows:
# Create your first MLP in Kerasfrom keras.models import Sequentialfrom keras.layers import Denseimport numpy# Load Datadataset = numpy.loadtxt("population.csv", delimiter=",")# split into input (X) and output (Y) variablesX = dataset[:,0:10]Y = dataset[:,10]# create modelmodel = Sequential()
The step for adding layers to a model is as follows:
model.add(Dense(12, input_dim=10, activation='relu'))model.add(Dense(10, activation='relu'))
The step to compile a model is as follows:
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) ...