Neural network architecture

Now that we've defined the input and output, we can take a look at the code for the network.

from keras.layers import Input, Densefrom keras.models import Modeldef build_network(input_features=None):    inputs = Input(shape=(input_features,), name="input")    x = Dense(32, activation='relu', name="hidden")(inputs)    prediction = Dense(1, activation='linear', name="final")(x)    model = Model(inputs=inputs, outputs=prediction)    model.compile(optimizer='adam', loss='mean_absolute_error')    return model

That's all there is to it! We can then use this code to build a neural network instance suitable for our problem simply by calling it, as follows:

model = build_network(input_features=10)

Before we get to that, however, let's review ...

Get Deep Learning Quick Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.