Skip to Content
Deep Learning with Keras
book

Deep Learning with Keras

by Antonio Gulli, Sujit Pal
April 2017
Intermediate to advanced
318 pages
7h 40m
English
Packt Publishing
Content preview from Deep Learning with Keras

Recycling pre-built deep learning models for extracting features

One very simple idea is to use VGG-16 and, more generally, DCNN, for feature extraction. This code implements the idea by extracting features from a specific layer:

from keras.applications.vgg16 import VGG16from keras.models import Modelfrom keras.preprocessing import imagefrom keras.applications.vgg16 import preprocess_inputimport numpy as np# pre-built and pre-trained deep learning VGG16 modelbase_model = VGG16(weights='imagenet', include_top=True)for i, layer in enumerate(base_model.layers):     print (i, layer.name, layer.output_shape)# extract features from block4_pool blockmodel =Model(input=base_model.input, output=base_model.get_layer('block4_pool').output)img_path = 'cat.jpg' ...
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

Advanced Deep Learning with Keras

Advanced Deep Learning with Keras

Rowel Atienza, Neeraj Verma, Valerio Maggio
Deep Learning with TensorFlow 2 and Keras - Second Edition

Deep Learning with TensorFlow 2 and Keras - Second Edition

Antonio Gulli, Dr. Amita Kapoor, Sujit Pal

Publisher Resources

ISBN: 9781787128422Supplemental Content