16.03.2021 Views

Advanced Deep Learning with Keras

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 1

model.add(Activation('relu'))

model.add(Dropout(dropout))

model.add(Dense(hidden_units))

model.add(Activation('relu'))

model.add(Dropout(dropout))

model.add(Dense(num_labels))

# this is the output for one-hot vector

model.add(Activation('softmax'))

Since a Dense layer is a linear operation, a sequence of Dense layers can only

approximate a linear function. The problem is that the MNIST digit classification is

inherently a non-linear process. Inserting a relu activation between Dense layers will

enable MLPs to model non-linear mappings. relu or Rectified Linear Unit (ReLU)

is a simple non-linear function. It's very much like a filter that allows positive inputs

to pass through unchanged while clamping everything else to zero. Mathematically,

relu is expressed in the following equation and plotted in Figure 1.3.5:

relu(x) = max(0,x)

Figure 1.3.5: Plot of ReLU function. The ReLU function introduces non-linearity in neural networks.

[ 13 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!