Probabilistic Deep Learning: With Python, Keras and TensorFlow Probability - mobi by Oliver Dürr & Beate Sick & Elvis Murina

Probabilistic Deep Learning: With Python, Keras and TensorFlow Probability - mobi by Oliver Dürr & Beate Sick & Elvis Murina

Author:Oliver Dürr & Beate Sick & Elvis Murina
Language: eng
Format: mobi
Publisher: Manning Publications Co.
Published: 2020-11-08T23:00:00+00:00


def NLL(y, distr):

return -distr.log_prob(y) ❶

def my_dist(params): ❷

return tfd.Normal(loc=params, scale=1)

# set the sd to the fixed value 1

inputs = Input(shape=(1,))

params = Dense(1)(inputs) ❸

dist = tfp.layers.DistributionLambda(my_dist)(params) ❹

model_sd_1 = Model(inputs=inputs, outputs=dist) ❺

model_sd_1.compile(Adam(), loss=NLL) ❻

❶ Computes the NLL of an observed y under the fitted distribution distr

❷ Uses the output of the last layer (params) as the parameter(s) of a distribution

❸ Sets up the NN with one output node

❹ Calls a distributional layer to take the function my_dist with the argument params

❺ Connects the output of the NN with a distribution

❻ Compiles the model with NLL as a loss function

With the TFP code in listing 5.2, you’ve fitted a linear regression model. But is it a probabilistic model? A probabilistic model needs to provide a whole CPD for the output for each input x. In the case of a Gaussian CPD, this not only requires an estimated mean μ x but also a standard deviation σ. In the standard linear regression case, a constant variance is chosen independently of the x position. In this case, we can estimate σ2 by the variance of the residuals. This means you first need to fit the linear model before you can determine the variance that is used for all CPDs.

Now you’re ready to use the trained model to do some probabilistic predictions on your validation data. For each test point, you’ll predict a Gaussian CPD. To visualize how the model performs on the validation data, you can draw the validation data along with the predicted mean of the CPD, μ x(see the solid line in figure 5.4), and the mean plus/minus two times the standard deviation of the CPD, μxi ± 2 ⋅ σx corresponding to the 0.025 and 0.975 quantiles (see the dashed lines in figure 5.4).



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Whisky: Malt Whiskies of Scotland (Collins Little Books) by dominic roskrow(55937)
What's Done in Darkness by Kayla Perrin(26544)
Shot Through the Heart: DI Grace Fisher 2 by Isabelle Grey(19018)
The Fifty Shades Trilogy & Grey by E L James(18992)
Shot Through the Heart by Mercy Celeste(18893)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 10 by Isuna Hasekura and Jyuu Ayakura(17020)
Python GUI Applications using PyQt5 : The hands-on guide to build apps with Python by Verdugo Leire(16902)
Peren F. Statistics for Business and Economics...Essential Formulas 3ed 2025 by Unknown(16827)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 03 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16742)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 01 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16366)
The Subtle Art of Not Giving a F*ck by Mark Manson(14287)
The 3rd Cycle of the Betrayed Series Collection: Extremely Controversial Historical Thrillers (Betrayed Series Boxed set) by McCray Carolyn(14084)
Stepbrother Stories 2 - 21 Taboo Story Collection (Brother Sister Stepbrother Stepsister Taboo Pseudo Incest Family Virgin Creampie Pregnant Forced Pregnancy Breeding) by Roxi Harding(13479)
Scorched Earth by Nick Kyme(12727)
Drei Generationen auf dem Jakobsweg by Stein Pia(10930)
Suna by Ziefle Pia(10857)
Scythe by Neal Shusterman(10292)
International Relations from the Global South; Worlds of Difference; First Edition by Arlene B. Tickner & Karen Smith(9489)
Successful Proposal Strategies for Small Businesses: Using Knowledge Management ot Win Govenment, Private Sector, and International Contracts 3rd Edition by Robert Frey(9337)
This is Going to Hurt by Adam Kay(9118)