Reader small image

You're reading from  The Deep Learning with Keras Workshop

Product typeBook
Published inJul 2020
Reading LevelIntermediate
PublisherPackt
ISBN-139781800562967
Edition1st Edition
Languages
Tools
Right arrow
Authors (3):
Matthew Moocarme
Matthew Moocarme
author image
Matthew Moocarme

Matthew Moocarme is an accomplished data scientist with more than eight years of experience in creating and utilizing machine learning models. He comes from a background in the physical sciences, in which he holds a Ph.D. in physics from the Graduate Center of CUNY. Currently, he leads a team of data scientists and engineers in the media and advertising space to build and integrate machine learning models for a variety of applications. In his spare time, Matthew enjoys sharing his knowledge with the data science community through published works, conference presentations, and workshops.
Read more about Matthew Moocarme

Mahla Abdolahnejad
Mahla Abdolahnejad
author image
Mahla Abdolahnejad

Mahla Abdolahnejad is a Ph.D. candidate in systems and computer engineering with Carleton University, Canada. She also holds a bachelor's degree and a master's degree in biomedical engineering, which first exposed her to the field of artificial intelligence and artificial neural networks, in particular. Her Ph.D. research is focused on deep unsupervised learning for computer vision applications. She is particularly interested in exploring the differences between a human's way of learning from the visual world and a machine's way of learning from the visual world, and how to push machine learning algorithms toward learning and thinking like humans.
Read more about Mahla Abdolahnejad

Ritesh Bhagwat
Ritesh Bhagwat
author image
Ritesh Bhagwat

Ritesh Bhagwat has a master's degree in applied mathematics with a specialization in computer science. He has over 14 years of experience in data-driven technologies and has led and been a part of complex projects ranging from data warehousing and business intelligence to machine learning and artificial intelligence. He has worked with top-tier global consulting firms as well as large multinational financial institutions. Currently, he works as a data scientist. Besides work, he enjoys playing and watching cricket and loves to travel. He is also deeply interested in Bayesian statistics.
Read more about Ritesh Bhagwat

View More author details
Right arrow

About the 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.

Audience

If you know the basics of data science and machine learning and want to get started with advanced machine learning technologies like artificial neural networks and deep learning, then this is the book for you. To grasp the concepts explained in this deep learning book more effectively, prior experience in Python programming and some familiarity with statistics and logistic regression are a must.

About the Chapters

Chapter 1, Introduction to Machine Learning with Keras, will introduce you to the fundamental concepts of machine learning by using the scikit-learn package. You will learn how to present data for model building, then train a logistic regression model using a real-world dataset.

Chapter 2, Machine Learning versus Deep Learning, will present the difference between traditional machine learning algorithms and deep learning algorithms. You will learn the linear transformations necessary for building neural networks and build your first neural network with the Keras library.

Chapter 3, Deep Learning with Keras, will extend your knowledge of neural network building. You will learn how to build multi-layer neural networks and recognize when your model is underfitting or overfitting to the training data.

Chapter 4, Evaluating Your Model with Cross-Validation Using Keras Wrappers, will teach you how to use Keras wrappers with scikit-learn to incorporate Keras models into a scikit-learn workflow. You will apply cross-validation to evaluate your models and use this technique to choose the optimal hyperparameters.

Chapter 5, Improving Model Accuracy, will introduce various regularization techniques to prevent your models from overfitting to the training data. You will learn different methods to search for the optimal hyperparameters that result in the highest model accuracy.

Chapter 6, Model Evaluation, will demonstrate a variety of methods to evaluate your models. Beyond accuracy, you will learn more model evaluation metrics including sensitivity, specificity, precision, false positive rate, ROC curves, and AUC scores to understand how well your models perform.

Chapter 7, Computer Vision with Convolutional Neural Networks, will introduce you to building image classifiers with convolutional neural networks. You will learn about all the components that comprise the architecture of convolutional neural networks and then build image processing applications to classify images.

Chapter 8, Transfer Learning and Pre-Trained Models, will introduce you to the concept of transferring the learning from one model to solve for other applications. You will achieve this by using different pre-trained models and modifying them slightly to fit different applications.

Chapter 9, Sequential Modeling with Recurrent Neural Networks, will teach you how to build models with sequential data. You will learn the architecture of recurrent neural networks and how to train them to predict the succeeding values from sequential data. You will test your knowledge by predicting the future values of various stock prices.

Conventions

Code words in text, database table names, folder names, filenames, file extensions, path names, dummy URLs, user input, and Twitter handles are shown as follows:

"sklearn has a class called train_test_split, which provides the functionality for splitting data."

Words that you see on the screen, for example, in menus or dialog boxes, also appear in the same format.

A block of code is set as follows:

# import libraries
import pandas as pd
from sklearn.model_selection import train_test_split

New terms and important words are shown like this:

"A dictionary contains multiple elements, like a list, but each element is organized as a key-value pair."

Code Presentation

Lines of code that span multiple lines are split using a backslash ( \ ). When the code is executed, Python will ignore the backslash, and treat the code on the next line as a direct continuation of the current line.

For example:

history = model.fit(X, y, epochs=100, batch_size=5, verbose=1, \
                   validation_split=0.2, shuffle=False)

Comments are added into code to help explain specific bits of logic. Single-line comments are denoted using the # symbol, as follows:

# Print the sizes of the dataset
print("Number of Examples in the Dataset = ", X.shape[0])
print("Number of Features for each example = ", X.shape[1])

Multi-line comments are enclosed by triple quotes, as shown below:

"""
Define a seed for the random number generator to ensure the 
result will be reproducible
"""
seed = 1
np.random.seed(seed)
random.set_seed(seed)

Setting up Your Environment

Before we explore the book in detail, we need to set up specific software and tools. In the following section, we shall see how to do that.

Installing Anaconda

For this course, we will use Anaconda; a Python distribution which comes with an in-built package manager and pre-installed packages frequently used for machine learning and scientific computing,

To install Anaconda, find your desired version (Windows, macOS, or Linux) on the official installation page at https://docs.anaconda.com/anaconda/install/. Follow the appropriate installation instructions for your operating system.

Once Anaconda is installed, you can interact with it via the Anaconda Navigator or Anaconda Prompt. There are instructions on how to use these at https://docs.anaconda.com/anaconda/user-guide/getting-started/.

To verify the correct installation, you can execute the anaconda-navigator command on CMD / Terminal. If the installation is correct, this will open up the Anaconda Navigator.

Installing Libraries

pip comes pre-installed with Anaconda. Once Anaconda is installed on your machine, all the required libraries can be installed using pip, for example, pip install numpy. Alternatively, you can install all the required libraries using pip install –r requirements.txt. You can find the requirements.txt file at https://packt.live/3hhZ2v9.

The exercises and activities will be executed in Jupyter Notebooks. Jupyter is a Python library and can be installed in the same way as the other Python libraries – that is, with pip install jupyter, but fortunately, it comes pre-installed with Anaconda.

Running Jupyter Notebook

You can start Jupyter via the appropriate link in the Anaconda Navigator, or by executing the command jupyter notebook in Anaconda Prompt / CMD / Terminal.

Jupyter will open up in your browser, where you will then be able to navigate to your working directory and create, edit and run your code files.

Accessing the Code Files

You can find the complete code files of this book at https://packt.live/2OL5E9t. You can also run many activities and exercises directly in your web browser by using the interactive lab environment at https://packt.live/2CXyFLS.

We've tried to support interactive versions of all activities and exercises, but we recommend a local installation as well for instances where this support isn't available.

The high-quality color images used in the book can found at https://packt.live/2u9Tno4.

If you have any issues or questions about installation, please email us at workshops@packt.com.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
The Deep Learning with Keras Workshop
Published in: Jul 2020Publisher: PacktISBN-13: 9781800562967
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (3)

author image
Matthew Moocarme

Matthew Moocarme is an accomplished data scientist with more than eight years of experience in creating and utilizing machine learning models. He comes from a background in the physical sciences, in which he holds a Ph.D. in physics from the Graduate Center of CUNY. Currently, he leads a team of data scientists and engineers in the media and advertising space to build and integrate machine learning models for a variety of applications. In his spare time, Matthew enjoys sharing his knowledge with the data science community through published works, conference presentations, and workshops.
Read more about Matthew Moocarme

author image
Mahla Abdolahnejad

Mahla Abdolahnejad is a Ph.D. candidate in systems and computer engineering with Carleton University, Canada. She also holds a bachelor's degree and a master's degree in biomedical engineering, which first exposed her to the field of artificial intelligence and artificial neural networks, in particular. Her Ph.D. research is focused on deep unsupervised learning for computer vision applications. She is particularly interested in exploring the differences between a human's way of learning from the visual world and a machine's way of learning from the visual world, and how to push machine learning algorithms toward learning and thinking like humans.
Read more about Mahla Abdolahnejad

author image
Ritesh Bhagwat

Ritesh Bhagwat has a master's degree in applied mathematics with a specialization in computer science. He has over 14 years of experience in data-driven technologies and has led and been a part of complex projects ranging from data warehousing and business intelligence to machine learning and artificial intelligence. He has worked with top-tier global consulting firms as well as large multinational financial institutions. Currently, he works as a data scientist. Besides work, he enjoys playing and watching cricket and loves to travel. He is also deeply interested in Bayesian statistics.
Read more about Ritesh Bhagwat