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

Predicting with CIFAR-10

Now let us suppose that we want to use the deep learning model we just trained for CIFAR-10 for a bulk evaluation of images. Since we saved the model and the weights, we do not need to train every time:

import numpy as npimport scipy.miscfrom keras.models import model_from_jsonfrom keras.optimizers import SGD#load modelmodel_architecture = 'cifar10_architecture.json'model_weights = 'cifar10_weights.h5'model = model_from_json(open(model_architecture).read())model.load_weights(model_weights)#load imagesimg_names = ['cat-standing.jpg', 'dog.jpg']imgs = [np.transpose(scipy.misc.imresize(scipy.misc.imread(img_name), (32, 32)),(1, 0, 2)).astype('float32')for img_name in img_names]imgs = np.array(imgs) / 255# trainoptim ...
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