Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Enhancing Deep Learning with Bayesian Inference

You're reading from   Enhancing Deep Learning with Bayesian Inference Create more powerful, robust deep learning systems with Bayesian deep learning in Python

Arrow left icon
Product type Paperback
Published in Jun 2023
Publisher Packt
ISBN-13 9781803246888
Length 386 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (3):
Arrow left icon
Matt Benatan Matt Benatan
Author Profile Icon Matt Benatan
Matt Benatan
Jochem Gietema Jochem Gietema
Author Profile Icon Jochem Gietema
Jochem Gietema
Marian Schneider Marian Schneider
Author Profile Icon Marian Schneider
Marian Schneider
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Chapter 1: Bayesian Inference in the Age of Deep Learning 2. Chapter 2: Fundamentals of Bayesian Inference FREE CHAPTER 3. Chapter 3: Fundamentals of Deep Learning 4. Chapter 4: Introducing Bayesian Deep Learning 5. Chapter 5: Principled Approaches for Bayesian Deep Learning 6. Chapter 6: Using the Standard Toolbox for Bayesian Deep Learning 7. Chapter 7: Practical Considerations for Bayesian Deep Learning 8. Chapter 8: Applying Bayesian Deep Learning 9. Chapter 9: Next Steps in Bayesian Deep Learning 10. Why subscribe?

5.5 Implementing BBB with TensorFlow

In this section, we’ll see how to implement BBB in TensorFlow. Some of the code you’ll see will be familiar; the core concepts of layers, loss functions, and optimizers will be very similar to what we covered in Chapter 3, Fundamentals of Deep Learning. Unlike the examples in Chapter 3, Fundamentals of Deep Learning, we’ll see how we can create neural networks capable of probabilistic inference.

Step 1: Importing packages

We start by importing the relevant packages. Importantly, we will import tensorflow-probability, which will provide us with the layers of the network that replace the point-estimate with a distribution and implement the reparameterization trick. We also set the global parameter for the number of inferences, which will determine how often we sample from the network later:

 
import tensorflow as tf  
import numpy as np  
import matplotlib.pyplot as plt  
import...
lock icon The rest of the chapter is locked
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.
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 €18.99/month. Cancel anytime
Modal Close icon
Modal Close icon