The output layer

And finally, we need an output layer for our network. We will use the following code to define our output layer:

prediction = Dense(1, activation='sigmoid', name="final")(x)

We're building a binary classifier in this example, so we want our network to output the probability the observation belongs to class 1. Luckily, the sigmoid activation will do exactly that, constraining the network output to be between 0 and 1.

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.