Define model architecture

Now we will build the model using the Keras functional API. As we saw before, first we have to define the input:

InputModel = Input(shape=(784,))

This returns a tensor that represents our input placeholder. Later, we will use this placeholder to define a Model. At this point, we can add layers to the architecture of our model:

EncodedLayer = Dense(32, activation='relu')(InputModel)

The Dense class is used to define a fully connected layer. We have specified the number of neurons in the layer as the first argument (32), the activation function using the activation argument (relu), and finally the input tensor (InputModel) of the layer.

Remember that given an input x, the encoder encodes it in a variable z, also called ...

Get Hands-On Machine Learning on Google Cloud Platform 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.