Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Enhancing Deep Learning with Bayesian Inference

You're reading from  Enhancing Deep Learning with Bayesian Inference

Product type Book
Published in Jun 2023
Publisher Packt
ISBN-13 9781803246888
Pages 386 pages
Edition 1st Edition
Languages
Authors (3):
Matt Benatan Matt Benatan
Profile icon Matt Benatan
Jochem Gietema Jochem Gietema
Profile icon Jochem Gietema
Marian Schneider Marian Schneider
Profile icon Marian Schneider
View More author details

Table of Contents (11) Chapters

Preface Chapter 1: Bayesian Inference in the Age of Deep Learning Chapter 2: Fundamentals of Bayesian Inference Chapter 3: Fundamentals of Deep Learning Chapter 4: Introducing Bayesian Deep Learning Chapter 5: Principled Approaches for Bayesian Deep Learning Chapter 6: Using the Standard Toolbox for Bayesian Deep Learning Chapter 7: Practical Considerations for Bayesian Deep Learning Chapter 8: Applying Bayesian Deep Learning Chapter 9: Next Steps in Bayesian Deep Learning 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 $15.99/month. Cancel anytime}