Book Image

The Deep Learning with Keras Workshop

By : Matthew Moocarme, Mahla Abdolahnejad, Ritesh Bhagwat
1 (1)
Book Image

The Deep Learning with Keras Workshop

1 (1)
By: Matthew Moocarme, Mahla Abdolahnejad, Ritesh Bhagwat

Overview of this book

New experiences can be intimidating, but not this one! This beginner’s guide to deep learning is here to help you explore deep learning from scratch with Keras, and be on your way to training your first ever neural networks. What sets Keras apart from other deep learning frameworks is its simplicity. With over two hundred thousand users, Keras has a stronger adoption in industry and the research community than any other deep learning framework. The Deep Learning with Keras Workshop starts by introducing you to the fundamental concepts of machine learning using the scikit-learn package. After learning how to perform the linear transformations that are necessary for building neural networks, you'll build your first neural network with the Keras library. As you advance, you'll learn how to build multi-layer neural networks and recognize when your model is underfitting or overfitting to the training data. With the help of practical exercises, you’ll learn to use cross-validation techniques to evaluate your models and then choose the optimal hyperparameters to fine-tune their performance. Finally, you’ll explore recurrent neural networks and learn how to train them to predict values in sequential data. By the end of this book, you'll have developed the skills you need to confidently train your own neural network models.
Table of Contents (11 chapters)
Preface

8. Transfer Learning and Pre-Trained Models

Activity 8.01: Using the VGG16 Network to Train a Deep Learning Network to Identify Images

Use the VGG16 network to predict the image given (test_image_1). Before you start, ensure that you have downloaded the image (test_image_1) to your working directory. Follow these steps to complete this activity:

  1. Import the numpy library and the necessary Keras libraries:
    import numpy as np
    from keras.applications.vgg16 import VGG16, preprocess_input
    from keras.preprocessing import image 
  2. Initiate the model (note that, at this point, you can also view the architecture of the network, as shown in the following code):
    classifier = VGG16()
    classifier.summary()

    classifier.summary() shows us the architecture of the network. The following points should be noted: it has a four-dimensional input shape (None, 224, 224, 3) and it has three convolutional layers.

    The last four layers of the output are as follows:

    Figure 8.16: The architecture of the...