Reader small image

You're reading from  Enhancing Deep Learning with Bayesian Inference

Product typeBook
Published inJun 2023
PublisherPackt
ISBN-139781803246888
Edition1st Edition
Right arrow
Authors (3):
Matt Benatan
Matt Benatan
author image
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.
Read more about Matt Benatan

Jochem Gietema
Jochem Gietema
author image
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.
Read more about Jochem Gietema

Marian Schneider
Marian Schneider
author image
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.
Read more about Marian Schneider

View More author details
Right arrow

5.7 Implementing PBP

Because PBP is quite complex, we’ll implement it as a class. Doing so will keep our example code tidy and allow us to easily compartmentalize our various blocks of code. It will also make it easier to experiment with, for example, if you want to explore changing the number of units or layers in your network.

Step 1: Importing libraries

We begin by importing various libraries. In this example, we will use scikit-learn’s California Housing dataset to predict house prices:

 
from typing import List, Union, Iterable  
import math  
from sklearn import datasets  
from sklearn.model_selection import train_test_split  
import tensorflow as tf  
import numpy as np  
from tensorflow.python.framework import tensor_shape  
import tensorflow_probability as tfp

To make sure we produce the same output every time, we initialize our seeds:

 
RANDOM_SEED...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Enhancing Deep Learning with Bayesian Inference
Published in: Jun 2023Publisher: PacktISBN-13: 9781803246888

Authors (3)

author image
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.
Read more about Matt Benatan

author image
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.
Read more about Jochem Gietema

author image
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.
Read more about Marian Schneider