Home Data Enhancing Deep Learning with Bayesian Inference

Enhancing Deep Learning with Bayesian Inference

By Matt Benatan , Jochem Gietema , Marian Schneider
ai-assist-svg-icon Book + AI Assistant
eBook + AI Assistant $49.99 $34.98
Print $59.99 $35.98
Subscription $15.99 $10 p/m for three months
ai-assist-svg-icon NEW: AI Assistant (beta) Available with eBook, Print, and Subscription.
ai-assist-svg-icon NEW: AI Assistant (beta) Available with eBook, Print, and Subscription. $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime! ai-assist-svg-icon NEW: AI Assistant (beta) Available with eBook, Print, and Subscription.
What do you get with a Packt Subscription?
Gain access to our AI Assistant (beta) for an exclusive selection of 500 books, available during your subscription period. Enjoy a personalized, interactive, and narrative experience to engage with the book content on a deeper level.
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
Gain access to our AI Assistant (beta) for an exclusive selection of 500 books, available during your subscription period. Enjoy a personalized, interactive, and narrative experience to engage with the book content on a deeper level.
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Along with your eBook purchase, enjoy AI Assistant (beta) access in our online reader for a personalized, interactive reading experience.
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
ai-assist-svg-icon NEW: AI Assistant (beta) Available with eBook, Print, and Subscription. ai-assist-svg-icon NEW: AI Assistant (beta) Available with eBook, Print, and Subscription. BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime! ai-assist-svg-icon NEW: AI Assistant (beta) Available with eBook, Print, and Subscription.
eBook + AI Assistant $49.99 $34.98
Print $59.99 $35.98
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
Gain access to our AI Assistant (beta) for an exclusive selection of 500 books, available during your subscription period. Enjoy a personalized, interactive, and narrative experience to engage with the book content on a deeper level.
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
Gain access to our AI Assistant (beta) for an exclusive selection of 500 books, available during your subscription period. Enjoy a personalized, interactive, and narrative experience to engage with the book content on a deeper level.
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Along with your eBook purchase, enjoy AI Assistant (beta) access in our online reader for a personalized, interactive reading experience.
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
  1. Free Chapter
    Chapter 2: Fundamentals of Bayesian Inference
About this book
Deep learning has an increasingly significant impact on our lives, from suggesting content to playing a key role in mission- and safety-critical applications. As the influence of these algorithms grows, so does the concern for the safety and robustness of the systems which rely on them. Simply put, typical deep learning methods do not know when they don’t know. The field of Bayesian Deep Learning contains a range of methods for approximate Bayesian inference with deep networks. These methods help to improve the robustness of deep learning systems as they tell us how confident they are in their predictions, allowing us to take more in how we incorporate model predictions within our applications. Through this book, you will be introduced to the rapidly growing field of uncertainty-aware deep learning, developing an understanding of the importance of uncertainty estimation in robust machine learning systems. You will learn about a variety of popular Bayesian Deep Learning methods, and how to implement these through practical Python examples covering a range of application scenarios. By the end of the book, you will have a good understanding of Bayesian Deep Learning and its advantages, and you will be able to develop Bayesian Deep Learning models for safer, more robust deep learning systems.
Publication date:
June 2023
Publisher
Packt
Pages
386
ISBN
9781803246888

 

Chapter 1
Bayesian Inference in the Age of Deep Learning

Over the last fifteen years, machine learning (ML) has gone from a relatively little-known field to a buzzword in the tech community. This is due in no small part to the impressive feats of neural networks (NNs). Once a niche underdog in the field, deep learning’s accomplishments in almost every conceivable application have resulted in a near-meteoric rise in its popularity. Its success has been so pervasive that, rather than being impressed by features afforded by deep learning, we’ve come to expect them. From applying filters in social networking apps, through to relying on Google Translate when on vacation abroad, it’s undeniable that deep learning is now well and truly embedded in the technology landscape.

But, despite all of its impressive accomplishments, and the variety of products and features it’s afforded us, deep learning has not yet surmounted its final hurdle. As sophisticated neural...

 

1.1 Technical requirements

All of the code for this book can be found on the GitHub repository for the book: https://github.com/PacktPublishing/Enhancing-Deep-Learning-with-Bayesian-Inference.

 

1.2 Wonders of the deep learning age

Over the last 10 to 15 years, we’ve seen a dramatic shift in the landscape of ML thanks to the enormous success of deep learning. Perhaps one of the most impressive feats of the universal impact of deep learning is that it has affected fields from medical imaging and manufacturing all the way through to tools for translation and content creation.

While deep learning has only seen great success over recent years, many of its core principles are already well established. Researchers have been working with neural networks for some time – in fact, one could argue that the first neural network was introduced by Frank Rosenblatt as early as 1957! This, of course, wasn’t as sophisticated as the models we have today, but it was an important component of these models: the perceptron, as shown in Figure 1.1.

PIC

Figure 1.1: Diagram of a single perceptron

The 1980s saw the introduction of many now-familiar concepts, with the introduction...

 

1.3 Understanding the limitations of deep learning

As we’ve seen, deep learning has achieved some remarkable feats, and it’s undeniable that it’s revolutionizing the way that we deal with data and predictive modeling. But deep learning’s short history also comprises darker tales: stories that bring with them crucial lessons for developing systems that are more robust, and, crucially, safer.

In this section, we’ll introduce a couple of key cases in which deep learning failed, and we will discuss how a Bayesian perspective could have helped to produce a better outcome.

1.3.1 Bias in deep learning systems

We’ll start with a textbook example of bias, a crucial problem faced by data-driven methods. This example centers around Amazon. Now a household name, the e-commerce company started out by revolutionizing the world of book retail, before becoming literally the one-stop shop for just about anything: from garden furniture to a new laptop, or even...

 

1.4 Core topics

The aim of this book is to provide you with the tools and knowledge you need to develop your own BDL solutions. To this end, while we assume some familiarity with concepts of statistical learning and deep learning, we will still provide a refresher of these fundamental concepts.

In Chapter 2, Fundamentals of Bayesian Inference, we’ll go over some of the key concepts from Bayesian inference, including probabilities and model uncertainty estimates. In Chapter 3, Fundamentals of Deep Learning, we’ll cover important key aspects of deep learning, including learning via backpropagation, and popular varieties of NNs. With these fundamentals covered, we’ll start to explore BDL in Chapter 4, Introducing Bayesian Deep Learning. In Chapters 5 and 6 we’ll delve deeper into BDL; we’ll first learn about principled methods, before going on to understand more practical methods for approximating Bayesian neural networks.

In Chapter ...

 

1.5 Setting up the work environment

To complete the practical elements of the book, you’ll need a Python 3.9 environment with the necessary prerequisites. We recommend using conda, a Python package manager specifically designed for scientific computing applications. To install conda, simply head to https://conda.io/projects/conda/en/latest/user-guide/install/index.html and follow the instructions for your operating system.

With conda installed, you can set up the conda environment that you’ll use for the book:

 
conda create -n bdl python=3.9

When you hit Enter to execute this command, you’ll be asked if you wish to continue installing the required packages; simply type y and hit Enter. conda will now proceed to install the core packages.

You can now activate your environment by typing the following:

 
conda activate bdl

You’ll now see that your shell prompt contains bdl, indicating that your conda environment is active. Now you...

 

1.6 Summary

In this chapter, we’ve revisited the successes of deep learning, renewing our understanding of its enormous potential, and its ubiquity within today’s technology. We’ve also explored some key examples of its shortcomings: scenarios in which deep learning has failed us, demonstrating the potential for catastrophic consequences. While BDL can’t eliminate these risks, it can allow us to build more robust ML systems that incorporate both the flexibility of deep learning and the caution of Bayesian inference.

In the next chapter, we’ll dive deeper into the latter as we cover some of the core concepts of Bayesian inference and probability, in preparation for our foray into BDL.

About the Authors
  • Matt Benatan

    Matt Benatan is a Principal Research Scientist at Sonos and a Simon Industrial Fellow at the University of Manchester. His work involves research in robust multimodal machine learning, uncertainty estimation, Bayesian optimization, and scalable Bayesian inference.

    Browse publications by this author
  • Jochem Gietema

    Jochem Gietema is an Applied Scientist at Onfido in London where he has developed and deployed several patented solutions related to anomaly detection, computer vision, and interactive data visualisation.

    Browse publications by this author
  • Marian Schneider

    Marian Schneider is an applied scientist in machine learning. His work involves developing and deploying applications in computer vision, ranging from brain image segmentation and uncertainty estimation to smarter image capture on mobile devices.

    Browse publications by this author