pytorch贝叶斯网络_贝叶斯神经网络:2个在TensorFlow和Pytorch中完全连接

pytorch贝叶斯网络

贝叶斯神经网络 (Bayesian Neural Net)

This chapter continues the series on Bayesian deep learning. In the chapter we’ll explore alternative solutions to conventional dense neural networks. These alternatives will invoke probability distributions over each weight in the neural network resulting in a single model that effectively contains an infinite ensemble of neural networks trained on the same data. We’ll use this knowledge to solve an important problem of our age: how long to boil an egg.

本章继续介绍贝叶斯深度学习系列。 在本章中,我们将探讨传统密集神经网络的替代解决方案。 这些替代方法将调用神经网络中每个权重的概率分布,从而产生一个有效包含对相同数据训练的神经网络的无限集合的单个模型。 我们将利用这些知识来解决我们这个时代的一个重要问题:煮鸡蛋要多长时间。

本章目标: (Chapter Objectives:)

  • Become familiar with variational inference with dense Bayesian models

    熟悉密集贝叶斯模型的变分推理
  • Learn how to convert a normal fully connected (dense) neural network to a Bayesian neural network

    了解如何将正常的完全连接(密集)神经网络转换为贝叶斯神经网络
  • Appreciate the advantages and shortcomings of the current implementation

    赞赏当前实施的优点和缺点

The data is from an experiment in egg boiling. The boil durations are provided along with the egg’s weight in grams and the finding on cutting it open. Findings are categorised into one of three classes: under cooked, soft-boiled and hard-boiled. We want the egg’s outcome from its weight and boiling time. The problem is insanely simple, so much so that the data is near being linearly separable¹⁠. But not quite, as the egg’s pre-boil life (fridge temperature or cupboard storage at room temperature) aren’t provided and as you’ll see this swings cooking times. Without the missing data we can’t be certain what we’ll find when opening an egg up. Knowing how certain we are we can influence the outcome here as we can with most problems. In this case if relatively confident an egg’s undercooked we’ll cook it more before cracking it open.

数据来自煮鸡蛋的实验。 提供煮沸的时间以及鸡蛋的重量(克)和切开鸡蛋的发现。 调查结果分为以下三类之一:未煮熟,软煮和硬煮。 我们想要鸡蛋的重量和煮沸时间来获得结果。 这个问题非常简单,以至于数据几乎可以线性分离。 但事实并非如此,因为没有提供鸡蛋的预煮寿命(冰箱温度或橱柜在室温下存储),并且您会看到这会改变烹饪时间。 没有缺少的数据,我们将无法确定打开鸡蛋时会发现什么。 知道自己的确定性,我们可以像对待大多数问题一样在这里影响结果。 在这种情况下,如果对鸡蛋未完全煮熟有相对的把握,我们会在将其打开之前将其煮熟。

Image for post

Let’s have a look at the data first to see what we’re dealing with. If you want to feel the difference for yourself you can get the data at github.com/DoctorLoop/BayesianDeepLearning/blob/master/egg_times.csv. You’ll need Pandas and Matplotlib for exploring the data. (pip install — upgrade pandas matplotlib) Download the dataset to the same directory you’re working from. From a Jupyter notebook type pwd on its own in a cell to find out where that directory is if unsure.

首先让我们看一下数据,看看我们正在处理什么。 如果您想自己感觉与众不同,可以在github.com/DoctorLoop/BayesianDeepLearning/blob/master/egg_times.csv上获取数据。 您将需要Pandas和Matplotlib来浏览数据。 (pip安装-升级pandas matplotlib)将数据集下载到您正在使用的目录中。 在Jupyter笔记本中,在一个单元格中单独键入pwd,以查明该目录在哪里(如果不确定)。

Image for post
https://gist.github.com/DoctorLoop/5a8633691f912d403e04a663fe02e6aa https://gist.github.com/DoctorLoop/5a8633691f912d403e04a663fe02e6aa
Image for post
Image for post
https://gist.github.com/DoctorLoop/21e30bdf16d1f88830666793f0080c63 https://gist.github.com/DoctorLoop/21e30bdf16d1f88830666793f0080c63
Image for post
Figure 2.01 Scatter plot of egg outcomes 图2.01鸡蛋结果散布图

And let’s see it now as a histogram.

现在让我们将其视为直方图。

Image for post
https://gist.github.com/DoctorLoop/2a5e95a68a29315f167e0e875e7fae16
  • 4
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值