Skip to Content
Deep Learning Quick Reference
book

Deep Learning Quick Reference

by Mike Bernico
March 2018
Intermediate to advanced
272 pages
7h 53m
English
Packt Publishing
Content preview from Deep Learning Quick Reference

Transfer network architecture

We will be replacing the final two layers with fully connected layers that are more appropriate for our use case. Since our problem is binary classification, we will replace the output layer with a single neuron with sigmoid activation, as shown in the following code:

# add a global spatial average pooling layerx = base_model.outputx = GlobalAveragePooling2D()(x)# let's add a fully-connected layerx = Dense(1024, activation='relu')(x)# and a logistic layerpredictions = Dense(1, activation='sigmoid')(x)# this is the model we will trainmodel = Model(inputs=base_model.input, outputs=predictions)

Note that we are using a GlobalAveragePooling2D layer here. This layer flattens the 4D output of the previous layer into ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Keras Deep Learning Cookbook

Keras Deep Learning Cookbook

Rajdeep Dua, Sujit Pal, Manpreet Singh Ghotra
Deep Learning with Keras

Deep Learning with Keras

Antonio Gulli, Sujit Pal

Publisher Resources

ISBN: 9781788837996Supplemental Content