imtoken钱包下载安装注册|pyro
Pyro
Pyro
Navigation
About
Install
Docs
Examples
Forum
GitHub
NumPyro (Beta)
Funsor (Beta)
Pyro
Deep Universal Probabilistic Programming
Install
Docs
Forum
Examples
About Pyro
NumPyro Release We’re excited to announce the release of NumPyro, a NumPy-backed Pyro using JAX for automatic differentiation and JIT compilation, with over 100x speedup for HMC and NUTS! See the examples and documentation for more details.
Pyro is a universal probabilistic programming language (PPL) written in Python and supported by PyTorch on the backend. Pyro enables flexible and expressive deep probabilistic modeling, unifying the best of modern deep learning and Bayesian modeling. It was designed with these key principles:
Universal: Pyro can represent any computable probability distribution.
Scalable: Pyro scales to large data sets with little overhead.
Minimal: Pyro is implemented with a small core of powerful, composable abstractions.
Flexible: Pyro aims for automation when you want it, control when you need it.
Check out the blog post for more background or dive into the tutorials.
How to Install Pyro
Pyro supports Python 3.
Install via Pip
First install PyTorch. Then install Pyro via pip:
pip3 install pyro-ppl
Install from source
git clone https://github.com/pyro-ppl/pyro.git
cd pyro
pip install .[extras]
Running Docker Image
Follow the instructions here.
Pyro is an Apache 2.0-Licensed Open Source Project
If you use Pyro or NumPyro in your research, please consider citing our papers.
@article{bingham2018pyro,
author = {Bingham, Eli and Chen, Jonathan P. and Jankowiak, Martin and Obermeyer, Fritz and
Pradhan, Neeraj and Karaletsos, Theofanis and Singh, Rohit and Szerlip, Paul and
Horsfall, Paul and Goodman, Noah D.},
title = {{Pyro: Deep Universal Probabilistic Programming}},
journal = {Journal of Machine Learning Research},
year = {2018}
}
@article{phan2019composable,
author = {Phan, Du and Pradhan, Neeraj and Jankowiak, Martin},
title = {Composable Effects for Flexible and Accelerated Probabilistic Programming in NumPyro},
journal = {arXiv preprint arXiv:1912.11554},
year = {2019}
}
Institutions Using Pyro:
(Add yours too!)
Pyro 从入门到出门 - 知乎
Pyro 从入门到出门 - 知乎首发于机器不学习切换模式写文章登录/注册Pyro 从入门到出门日知图卷积网络/生成模型有很多同学在入坑 Link Prediction 后私信我概率分布相关的问题。后来我仔细想了想,发现搞机器学习的同学大(就)部(是)分(我)在线性代数、矩阵论、微积分上没什么问题,但是概率论、信息论的知识还是有很大空白的。因此,这里给大家推荐一个现成的库 Pyro。从 Pytorch 中的概率分布说起Pytorch 在 torch.distributions 中为我们提供了常见的概率分布,使用这些概率分布我们可以轻松的生成符合预期的随机变量:m = Bernoulli(torch.tensor([0.3]))
m.sample()
# tensor([ 0.])
# 有 30% 可能性出现 1,70% 可能性出现 0一个概率分布可以由概率分布函数和参数确定,常用的概率分布有以下几种:正态(高斯)分布m = Normal(torch.tensor([0.0]), torch.tensor([1.0]))
m.sample()
# tensor([ 0.1046])指数分布m = Exponential(torch.tensor([1.0]))
m.sample()
# tensor([ 0.1046])二项(伯努利)分布m = Bernoulli(torch.tensor([0.3]))
m.sample()
# tensor([ 0.])泊松分布m = Poisson(torch.tensor([4]))
m.sample()
# tensor([ 3.])有些同学可能只会在初始化参数矩阵的时候用到概率分布。随着神经网络的发展,概率模型被吸收和同化,我们越来越多地在神经网络中使用概率分布建模:它赋予了模型表达随机事件的能力,也在一定程度上带来了优化的困难。概率计算图的反向传递在神经网络中,我们想要让模型调整某个表达式的参数,最小化某个目标函数。Hinton 已经告诉我们,这可以通过反向传播(计算图)完成。在随机模型中,我们还想要让模型调整某个概率分布的参数,最小化某个目标函数。这时,计算图中就包含随机(抽样)节点了,我们可以对反向传播(计算图)进行改造,主要有两种思路:Score Function有些抽样无法写出明确的表达式,比如在 0\sim k 中随机选择一个整数。对于这种情况,我们可以使用 Score Function 方法进行反向传递:在正向传递时,采集一些样本 x ,使用这些样本计算 f(x) ( f 为采样后的操作)作为抽样的得分,并所有样本的平均分(以概率的对数 log(p(x|\theta)) 为权),以此作为分布的得分;在反向传递时,以得分作为梯度。在 Pytorch 中,我们只需要调用 sample 就可以了:probs = policy_network(state)
# Note that this is equivalent to what used to be called multinomial
m = Categorical(probs)
action = m.sample()
next_state, reward = env.step(action)
loss = -m.log_prob(action) * reward
loss.backward()这样做需要的抽样规模较大(batch 较大),而且在高维空间优化比较困难(方差大)。Pathwise Dervative有些抽样可以分解为独立噪声和仿射变换,写出明确的表达式,比如在正态分布 x\sim N(\mu,\sigma^2) 可以写成 x=\mu + \sigma\varepsilon,\varepsilon \sim N(0,1) 。对于这种情况,我们可以使用 Pathwise Dervative 进行反向传递,使用 Reparameter Trick 将独立噪声分离出来:在正向传播时,生成一个独立噪声 \varepsilon ,使用 \mu 和 \sigma 对 \varepsilon 进行仿射变换,模拟抽样过程;在反向传播时,使用 f(x) 的梯度信息对 \mu 和 \sigma 进行移动,从而达到调整概率分布的目的。在 Pytorch 中,我们只需要调用 rsample 就可以了:params = policy_network(state)
m = Normal(*params)
action = m.rsample()
next_state, reward = env.step(action)
loss = -reward
loss.backward()对于某些难以表示的概率分布,这种方法可能效果较差。对上述两种方法的推导及证明感兴趣的同学可以看这里。就实现而言,Pytorch 已经帮助我们隐藏了这些细节。只需要记住,在增强学习中要调用 sample,在 VAE 中要调用 rsample 就可以了。其他概率编程语言(PPL)以前,贝叶斯神经网络在神经网络的浪潮中不算瞩目,但是近年来,自动编码器(VAE)和增强学习越来越火,概率神经网络在自然语言处理(NLP)、自动驾驶等领域攻城略地,直接使用 Pytorch 指定复杂的概率模型(除了上面讲到的,还有其他更麻烦的实现)似乎有点捉襟见肘。在这种情况下,概率编程语言(PPL)的研究越来越火。科研和工程领域都希望 PPL 能够帮助我们直接指定概率事件,不用再关心其实现和优化细节。其中,最出名的两个库是:Edward(谷歌实现,基于 Tensorflow)Pyro(Uber 实现,基于 Pytorch)选哪个好呢,这就又回到了 TF 男孩和 PT 男孩之间的真理标准问题大讨论。不过说正经的,个人感觉 Pyro 的实现比较丰富,因此推荐各位同学使用 Pyro 上手,Edward 的使用大同小异。(当然,要是只会 TF 的话也可以先学 Edward)Pyro 封装了什么作为 GPU 上的 numpy,Pytorch 最擅长的是 Tensor 的管理、各种矩阵运算和反向传播。但是它在推理算法上的实现比较有限。Pyro 利用 Pytorch 在 GPU 上的反向传播,定义了随机计算图的更新方法。在使用 Pyro 时,我们不需要手动区分 sample 和 resample。# pytorch
normal = torch.distributions.Normal(loc, scale)
x = normal.rsample()
# pyro
x = pyro.sample("my_sample", pyro.distributions.Normal(loc, scale))在贝叶斯推断中,先验分布反应了实验前对总体参数分布的认识,在获得样本后人们会对这个认识进行调整形成后验分布。只要找到后验分布,就相当于找到了样本(输入)和试验结果(输出)之间的规律,能够进行预测等工作了。由于后验分布的影响因素较为复杂,往往无法直接求得。我们一般根据先验知识和试验数据设计一个后验概率模型(model),再使用一个较为简单的分布(guide)去逼近它。这里我们举一个抛硬币的例子,说明 Pyro 的实现。在抛硬币实验中,我们抛出 10 次硬币,正面向上的次数为 6(试验数据),反面向上的次数为 4:# 数据集
data = []
for _ in range(6):
data.append(torch.tensor(1.0))
for _ in range(4):
data.append(torch.tensor(0.0))我们都知道,抛出一枚硬币,正面向上的概率为 1/2(先验知识)。但是这次试验的试验结果让我们怀疑这枚硬币密度不均匀,需要调整正面向上概率的认知。综合先验知识和试验数据,我们可以这样设计 model:def model(data):
# 先验知识,正面向上的概率为 1/2
alpha0 = torch.tensor(10.0)
beta0 = torch.tensor(10.0)
f = pyro.sample("latent_fairness", dist.Beta(alpha0, beta0))
# 试验数据,抽样的结果为实际观测值 6/10
for i in range(len(data)):
pyro.sample("obs_{}".format(i), dist.Bernoulli(f), obs=data[i])
# Pyro 希望用户使用 obs 声明观测值这里的 model 比较简单,我们甚至可以手动计算出真实的后验分布模型。但是,在实际应用中,它可能是一个复杂的非线性映射(比如神经网络)。在这种情况下我们往往无法直接求得后验概率模型,需要定义一个简单的分布(guide)去逼近后验概率模型:# Pyro 将训练参数封装为 pyro.param,在反向传播时 Pyro 会帮我们管理这些参数的更新,参数值可以初始化成任何值。
def guide(data):
alpha_q = pyro.param("alpha_q", torch.tensor(15.0),
constraint=constraints.positive)
beta_q = pyro.param("beta_q", torch.tensor(15.0),
constraint=constraints.positive)
pyro.sample("latent_fairness", dist.Beta(alpha_q, beta_q))如何让定义的简单分布(guide)逼近模型(model)呢?我们可以考虑最小化每次采样(pyro.sample)中,guide 和 model 的分布差异:# Pyro 会在计算时对齐 guide 和 model 中的同名的概率分布
# 在求 loss 时,对应的概率分布的差异会被计算
# model
# name == latent_fairness
f = pyro.sample("latent_fairness", dist.Beta(alpha0, beta0))
# guide
# name == latent_fairness
pyro.sample("latent_fairness", dist.Beta(alpha_q, beta_q))这里提醒一下:model 可以比 guide 复杂得多,但是一定不要忘记 guide 中的具名采样一定要在 model 中出现(可以不是同一种采样方式,但是一定要有对应的名称)。衡量两个采样概率分布的差异我们可以使用 KL 散度,要使 guide 逼近 model 只需要最小化所有采样的 KL 散度之和:\theta'=\mathop{\arg\min}_{\theta}KL(q_{\theta}(z)||p(z|x))\\ 这个公式等价于最大化 ELBO:\theta'=\mathop{\arg\max}_{\theta}\mathbb{E}_q[logp(x,z)-log(q_{\theta}(z))]\\ 我们可以使用 Pyro 提供的 ELBO 损失函数,训练过程与 Pytorch 大同小异:adam_params = {"lr": 0.0005, "betas": (0.90, 0.999)}
optimizer = Adam(adam_params)
svi = SVI(model, guide, optimizer, loss=Trace_ELBO())
for step in range(n_steps):
svi.step(data)贝叶斯神经网络的实现与上面的例子类似,只是 model 和 guide 的实现稍微复杂一点,是神经网络的形式。这里看一个线性回归的例子:# 线性回归
class RegressionModel(nn.Module):
def __init__(self, p):
# p = number of features
super(RegressionModel, self).__init__()
self.linear = nn.Linear(p, 1)
self.factor = nn.Parameter(torch.tensor(1.))
def forward(self, x):
return self.linear(x) + (self.factor * x[:, 0] * x[:, 1]).unsqueeze(1)
# 贝叶斯线性回归
def model(is_cont_africa, ruggedness, log_gdp):
a = pyro.sample("a", dist.Normal(8., 1000.))
b_a = pyro.sample("bA", dist.Normal(0., 1.))
b_r = pyro.sample("bR", dist.Normal(0., 1.))
b_ar = pyro.sample("bAR", dist.Normal(0., 1.))
sigma = pyro.sample("sigma", dist.Uniform(0., 10.))
mean = a + b_a * is_cont_africa + b_r * ruggedness + b_ar * is_cont_africa * ruggedness
with pyro.iarange("data", len(ruggedness)):
pyro.sample("obs", dist.Normal(mean, sigma), obs=log_gdp)
def guide(is_cont_africa, ruggedness, log_gdp):
a_loc = pyro.param('a_loc', torch.tensor(0.))
a_scale = pyro.param('a_scale', torch.tensor(1.),
constraint=constraints.positive)
sigma_loc = pyro.param('sigma_loc', torch.tensor(1.),
constraint=constraints.positive)
weights_loc = pyro.param('weights_loc', torch.randn(3))
weights_scale = pyro.param('weights_scale', torch.ones(3),
constraint=constraints.positive)
a = pyro.sample("a", dist.Normal(a_loc, a_scale))
b_a = pyro.sample("bA", dist.Normal(weights_loc[0], weights_scale[0]))
b_r = pyro.sample("bR", dist.Normal(weights_loc[1], weights_scale[1]))
b_ar = pyro.sample("bAR", dist.Normal(weights_loc[2], weights_scale[2]))
sigma = pyro.sample("sigma", dist.Normal(sigma_loc, torch.tensor(0.05)))
mean = a + b_a * is_cont_africa + b_r * ruggedness + b_ar * is_cont_africa * ruggedness对比神经网络和贝叶斯神经网络,我们会有这样的感觉:神经网络是一个无类型的编程语言,只能指定执行的流程(网络结构),而无法指定每个变量(训练参数)的类型(实际含义),完全由训练学出;而贝叶斯神经网络是一个静态类型的编程语言,除了定义执行的流程(网络结构,即 guide),还能指定变量的类型(后验分布表达式,即 model),训练结果相对可解释。有很多同学不喜欢这样的静态类型语言,没关系,我们可以像 typescript 一样,杂交~ 自动编码器就是一个很好的例子:class VAE(nn.Module):
def __init__(self, z_dim=50, hidden_dim=400, use_cuda=False):
super(VAE, self).__init__()
self.encoder = Encoder(z_dim, hidden_dim)
self.decoder = Decoder(z_dim, hidden_dim)
if use_cuda:
self.cuda()
self.use_cuda = use_cuda
self.z_dim = z_dim
# define the model p(x|z)p(z)
def model(self, x):
pyro.module("decoder", self.decoder)
with pyro.plate("data", x.shape[0]):
z_loc = x.new_zeros(torch.Size((x.shape[0], self.z_dim)))
z_scale = x.new_ones(torch.Size((x.shape[0], self.z_dim)))
z = pyro.sample("latent", dist.Normal(z_loc, z_scale).to_event(1))
loc_img = self.decoder.forward(z)
pyro.sample("obs", dist.Bernoulli(loc_img).to_event(1), obs=x.reshape(-1, 784))
def guide(self, x):
pyro.module("encoder", self.encoder)
with pyro.plate("data", x.shape[0]):
z_loc, z_scale = self.encoder.forward(x)
pyro.sample("latent", dist.Normal(z_loc, z_scale).to_event(1))
def reconstruct_img(self, x):
z_loc, z_scale = self.encoder(x)
z = dist.Normal(z_loc, z_scale).sample()
loc_img = self.decoder(z)
return loc_img我们不在意 encoder 和 decoder 中训练参数的概率分布(类型为 any),只考虑隐变量的概率分布(静态类型),并对这一部分定义 model 和 guide。vae = VAE()
optimizer = Adam({"lr": 1.0e-3})
svi = SVI(vae.model, vae.guide, optimizer, loss=Trace_ELBO())
def train(svi, train_loader, use_cuda=False):
epoch_loss = 0.
for x, _ in train_loader:
if use_cuda:
x = x.cuda()
epoch_loss += svi.step(x)
normalizer_train = len(train_loader.dataset)
total_epoch_loss_train = epoch_loss / normalizer_train
return total_epoch_loss_train结束总体来说,使用 Pyro 实现的概率模型还是很优雅的。即使对贝叶斯神经网络不感兴趣(说实话有点麻烦又效果一般),在 VAE 模型(还是挺常用的,值得一试)中使用 Pyro 也会让你的代码看起来更清晰。最近 tkipf 挖出了 GCN 的新坑,让 Graph 重新火了起来,不知道概率模型上能不能旧瓶装新酒,再来一波浪潮吖~~编辑于 2019-04-24 11:59PyTorch神经网络赞同 898 条评论分享喜欢收藏申请转载文章被以下专栏收录机器不学习讲一波自己都能看懂的深度
Uber与斯坦福大学开源深度概率编程语言Pyro:基于PyTorch - 知乎
Uber与斯坦福大学开源深度概率编程语言Pyro:基于PyTorch - 知乎首发于机器之心切换模式写文章登录/注册Uber与斯坦福大学开源深度概率编程语言Pyro:基于PyTorch机器之心数学等 2 个话题下的优秀答主近日,Uber AI Lab 与斯坦福大学的研究团队开源了全新概率编程语言 Pyro。该语言基于 Python 与 PyTorch 之上,专注于变分推理,同时支持可组合推理算法。Pyro 的目标是更加动态(通过使用 PyTorch)和通用(允许递归)。它有一个灵活的基元库,用于创建新的推理算法并使用概率程序。Pyro 中可组合推理的核心抽象是 poutine(Pyro Coroutine 的简称)。Pyro 的推理算法是通过将 poutine 应用于随机函数来构建的。项目链接:PyroGitHub 链接:uber/pyroUber 人工智能实验室刚刚宣布开源了概率编程语言(probabilistic programming language) Pyro!Pyro 是一个深度概率建模工具,有效融合了深度学习与贝叶斯建模,其目标是加速上述技术的研究与应用,更大地惠及人工智能社区。Uber 人工智能实验室既研究专业技术,又探索实际应用。我们整合人工智能中的多个分支,有着深度学习、贝叶斯方法、进化计算和强化学习等方面的专家。Pyro 本身汇集了最好的深度学习、贝叶斯建模和软件抽象技术,从而成为一个现代、通用的深度概率编程语言。我们相信,解决人工智能的关键所在是世界范围不同社区的共同努力。通过开源 Pyro,我们希望促进社区协作,使得 AI 工具更灵活、开放和易于使用。我们期待当前版本(alpha!)的 Pyro 能引起一些人的极大兴趣,包括想要利用大数据集和深度网络的概率建模者,想要更容易地使用贝叶斯计算的 PyTorch 用户,以及准备探索技术新前沿的数据科学家。下文将描述创建 Pyro 的动机,概述其设计原理及执行方面的一些见解,并指明下一步开发的状况。为何选择 Pyro?概率是推理不确定性的数学,正如微积分是推理变化率的数学。概率语言模型能够捕捉复杂的推理,发现未知,无需监督即可揭开数据的结构。并且,概率可使得专家通过先验信念的形式把知识注入到 AI 系统。直接指定概率模型是笨重的,其执行也容易出错。概率编程语言(PPL)通过联合概率与编程语言的表征力量来解决上述问题。概率程序是一般确定性计算和随机采样值的混合,随机计算表征了数据的生成性。这一表征中隐含着概率——没有必要去推导公式——但这一规范也是通用的:通过这种方式可以编写任意的可计算概率模型。Pyro 全部使用 Python 作为基础语言,清晰而令人熟悉。通过观察概率程序的结果,我们可以描述推断问题,大致为:「如果随机选择有个特定观测值,那么什么为真?」概率编程系统提供了通用的推断算法,只需用户很少的介入即可执行推断。试着把这看作 PPL 的编译器:它允许我们在建模器和推断专家之间分工。然而推断是概率建模的关键挑战,不可扩展的推理是 PPL 的主要失败模式。借助深度学习的力量,研究者最近为概率推断和 PPL 执行引入了一种新方法,其核心思想是通过第二个模型(被称作推断模型,或者 Pyro 指导/guide in Pyro)描述模型中的推断,实际上这一思想最早可追溯到 Helmholtz machine。正如模型表征了数据的生成性,指导表征了把数据转化为潜在选择的生成性。当然,我们不能简单地写下正确的指导(这就是为什么推断如此艰难)。相反,我们使用变分法,指定一组参数化的指导,接着解决一个优化问题从而把指导推进到模型的后验分布。这一优化可通过自动微分技术实现自动化,该技术能够有效计算程序的梯度,并提供评估期望值梯度的若干技巧。Pyro 构建在优秀的 PyTorch 库之上,后者包括使用非常快速、GPU 加速的张量数学的自动微分。PyTorch 动态构建梯度,使得 Pyro 程序包含随机控制结构,即 Pyro 程序中的随机选择能够控制其他随机选择的出现。随机控制结构是 PPL 通用的关键。因此,Pyro 能够表征任意概率模型,同时提供灵活、可扩展到大型数据集的自动优化推断。在 Pyro 中,生成模型和推断指导都可包括深度神经网络组件。最终的深度概率模型在最近工作中表现优异,尤其是对于无监督和半监督机器学习问题。总结:为什么要概率建模?为了正确捕捉模型中的不确定性和无监督、半监督学习的预测,并提供带有陈述式先验知识的 AI 系统。为什么是(通用)概率程序?为指定复杂模型提供一个清晰、高级而又完整的语言。为什么是深度概率模型?为了从数据中学习生成知识,并具化如何推断的知识。为什么通过优化推断?为了扩展到大数据并促进现代优化和变分推断的进步。Pyro 的设计原则和洞察在 Pyro 的开发过程中,我们的目标是满足四个设计原则。Pyro 的设计目标是:通用性:Pyro 是一个通用性 PPL—可表征任何可计算的概率分布。如何做到呢?通过从一种通用性语言(任意的 Python 代码)开始迭代和递归,然后添加随机采样、观测和推理。可扩展:只需要在原来的代码顶部添加少量的手写代码,Pyro 就可以扩展到大型数据集。如何做到呢?通过建立现代黑箱优化技术,其使用数据的小批量进行近似推理。最轻量:Pyro 是灵活和可维护的。如何做到呢?Pyro 是由少量强大而可组合的抽象概念实现的。任何繁重的工作都会尽可能用 PyTorch 和其它的库完成。灵活性:Pyro 的目标是根据用户意愿实现自动化和可控制。如何做到呢?Pyro 使用高级的抽象概念表达生成和推理模型,同时允许专家自定义推理。这些原则经常使 Pyro 的实现走向互为相反的方向。例如,为了实现通用性,需要在 Pyro 的程序中允许任意的控制结构,但这种通用性会导致其很难扩展。类似地,使用最少量的抽象概念的目标函数的自动构建使其更容易构建新的原型模型,但这也会使目标计算被隐藏,给那些需要灵活修改目标的高级用户造成不便。我们在研究过程中借用了其它 PPL 的技术(特别是 WebPPL 和 Edward)来分解这些问题,并发现了一些新方法,例如可组合效应的处理程序可清晰地从目标函数的计算中分离控制流操作。PPL 基础运算是从一个分布中采样、观测样本的值以及推理执行后的结果。然而,采样声明所需的行为依赖于所在的推理环境。例如,当计算标准的边际似然函数下界(evidence-lower-bound)目标时,指导中的采样声明需要在实际中采样新的值,而模型中的采样声明只能重用这些值。Pyro 的实现将这些依赖于具体环境的效应整合成一个「普丁」目标的集合(Poutine,Pyro Coroutine 的简称),比如 Trace、 Replay 和 Condition。每一个「普丁」提供了对 Pyro 结构的少量修改(采样、参数结构,等等)。将这些「普丁」层叠起来使我们能对不同的推理算法建立需要的操作。通过这种「普丁」式的编程逻辑,主要的推理代码都集中于构建目标和估计梯度上。下一步Pyro 的 alpha 版本已经足够用于研究,但在概率编程和深度学习社区的推动下,我们仍将继续在未来数月内对 Pyro 的版本进行快速迭代。基于 Pyro 的广泛应用领域和生机勃勃的深度概率建模和推理的研究社区,Pyro 进一步扩展和提升的可能方向是多方面的。我们最优先发展的技术包括:优化抽象概念以进行快速建模(例如,通过提供自动默认指导)和高级用途(例如,通过优化「普丁」目标的组成)。添加附加的目标(例如,alpha divergence、infoVAE 和 GAN-based loss)和附加的技术以估计梯度的期望值。添加马尔科夫链蒙特卡罗(MCMC)和序列蒙特卡罗推理,特别是哈密顿蒙特卡罗(HMC),并在变分推理目标中使用。探索高斯过程的模式和诸如贝叶斯优化的应用。在更长远的未来,我们希望 Pyro 的主要发展方向将通过应用驱动,并成为新兴的 Pyro 社区的优选项。安装首先安装 PyTorch:PyTorchPyro 的大多数功能都是在 PyTorch 0.2 版本上实现的,但其中的一些功能只能在 PyTorch 的主分支上可用(如 pyro.SVI(... enum_discrete=True) 和 pyro.SVI(..., num_particles=100) 需要高于 0.2 版本的 PyTorch)。为了正常使用这些功能,请从源文件安装 PyTorch。经开发者验证,f964105 支持所有的 Pyro 功能。该版本可从以下地址复制:pytorch/pytorch通过以下方法安装:Python 2.7:pip install pyro-pplPython 3.5:pip3 install pyro-ppl从源文件安装:git clone git@github.com:uber/pyro.git
cd pyro
pip install.选自Uber 机器之心编译编辑于 2017-11-04 11:58机器学习PyTorch优步(Uber)赞同 19513 条评论分享喜欢收藏申请转载文章被以下专栏收录机器之心关注人工智能学术和技
【概率编程利器--pyro库】官方API详细解读一 - 知乎
【概率编程利器--pyro库】官方API详细解读一 - 知乎首发于知识储备积累——数据科学篇切换模式写文章登录/注册【概率编程利器--pyro库】官方API详细解读一神奇锑知行合一占坑,边学边填补一、pyro库的安装创建虚拟环境 conda create -n xxx python=3.8,其中xxx为虚拟环境的名称。配置conda镜像:conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
conda config --set show_channel_urls yes安装 PyTorch,其次是 Pyro。最后根据代码配置常用的数据科学库,无需指定版本,安装默认的最新版本即可。二、pyro库介绍Pyro简介概率编程语言 (PPL) 通过将概率与编程语言的表示能力相结合来解决不确定性问题。概率程序是普通确定性计算和代表数据生成过程的随机采样值的混合。Pyro 是一种基于 Python 和 PyTorch 的概率编程语言。Pyro 程序只是 Python 程序,而其主要推理技术是随机变分推理,它将抽象的概率计算转化为 PyTorch 中随机梯度下降解决的具体优化问题,使概率方法适用于以前难以处理的模型和数据集大小。在本教程中,我们将简要介绍 Pyro 的概率机器学习[1]和概率编程的基本概念。我们通过一个涉及线性回归的示例数据分析问题来做到这一点,线性回归是机器学习中最常见和最基本的任务之一。我们将看到如何使用 Pyro 的建模语言和推理算法将不确定性纳入回归系数的估计中。大纲知识背景:概率机器学习Pyro中的模型Pyro中的推理Pyro中的模型评估知识背景:概率机器学习大多数数据分析问题都可以理解为对三个基本高级问题的阐述:在观察任何数据之前,我们对问题了解多少?根据我们的先验知识,我们可以从数据中得出什么结论?这些结论有意义吗?在数据科学和机器学习的概率或贝叶斯方法中,我们根据概率分布的数学运算将这些形式化。背景:概率模型首先,我们以概率模型或随机变量集合的联合概率分布的形式表达我们对问题中变量的了解以及它们之间的关系。模型具有观察值 \bold{x} 和潜在的随机变量 \bold{z} 以及参数 \theta 。它通常具有以下形式的联合密度函数p_{\theta}\left( \bold{x},\bold{z} \right) = p_{\theta}(\bold{x}|\bold{z})p_{\theta}(\bold{z})\\ 潜在变量的分布 p_{\theta}(\bold{z}) 在这个公式中称为先验,并且在给定潜在变量的情况下观察到的变量的分布 p_{\theta}(\bold{x}|\bold{z}) 称为似然。我们通常要求各种条件概率分布 p_i 组成一个模型 p_{\theta}\left( \bold{x},\bold{z} \right) 具有以下属性:我们可以有效地从每个样本中抽样 p_i 我们可以有效地计算逐点概率密度 p_i p_i 对参数 \theta 是可微的概率模型通常以用于可视化和交流的标准图形表示法来描述,总结如下,尽管在 Pyro 中可以表示没有固定图形结构的模型。在有很多重复的模型中,使用板符号很方便,之所以这样称呼是因为它以图形方式显示为围绕变量的矩形“板”,以指示内部随机变量的多个独立副本。背景:推理、学习和评估一旦我们指定了一个模型,贝叶斯规则就会告诉我们如何使用它来执行推理,或者通过计算后验分布从数据中得出关于潜在变量的结论 \bold{z} :p_\theta(\mathbf{z} \mid \mathbf{x})=\frac{p_\theta(\mathbf{x}, \mathbf{z})}{\int d \mathbf{z} p_\theta(\mathbf{x}, \mathbf{z})} \\为了检查建模和推理的结果,我们想知道模型与观察数据 \bold{x} 的拟合程度,我们可以用证据或边际似然来量化。p_\theta(\mathbf{x})=\int d \mathbf{z} p_\theta(\mathbf{x}, \mathbf{z})\\ 并对新数据进行预测,我们可以使用后验预测分布来做p_\theta\left(x^{\prime} \mid \mathbf{x}\right)=\int d \mathbf{z} p_\theta\left(x^{\prime} \mid \mathbf{z}\right) p_\theta(\mathbf{z} \mid \mathbf{x})\\ 最后,通常需要学习参数 \theta ,我们的模型来自观察数据 \bold{x} ,我们可以通过最大化边际似然来做到这一点:\theta_{\max }=\operatorname{argmax}_\theta \mathrm{p}_\theta(\mathbf{x})=\operatorname{argmax}_\theta \int \mathrm{d} \mathbf{z} \mathrm{p}_\theta(\mathbf{x}, \mathbf{z})\\Pyro中的模型贝叶斯线性回归模型为了让线性回归问题纳入贝叶斯体系中,我们需要给w和b以先验。也就是说,在未观察到任何数据前,我们对权重和偏置做合理的猜测。我们将使用PyroModule[nn.Linear]类组建模型。注意下面几点:BaysianRegression模块在内部和PyroModule[nn.Linear]模块的方法是一样的。不过我们不直接使用weight和bias,而是PyroSample模块。这样我们可以给weight和bias指定先验,而非认定它们是固定的学习参数。对于偏置,我们给先验设置较大的范围。BayesianRegression.forward方法进行产生过程。我们产生linear模块的激励产生均值(也就是采样先验得到weight和bias并返回平均激励),利用obs参数指定pyro.sample的观察变量y_data,其学习的参数是观察变量的方差sigma。模型返回贝叶斯回归的结果mean。from pyro.nn import PyroSample
class BayesianRegression(PyroModule):
def __init__(self, in_features, out_features):
super().__init__()
self.linear = PyroModule[nn.Linear](in_features, out_features)
self.linear.weight = PyroSample(dist.Normal(0., 1.).expand([out_features, in_features]).to_event(2))
self.linear.bias = PyroSample(dist.Normal(0., 1.).expand([out_features]).to_event(1))
#
def forward(self, x, y=None):
sigma = pyro.sample('sigma', dist.Uniform(0., 10.))
mean = self.linear(x).squeeze(-1)
with pyro.plate('data', x.shape[0]):
obs = pyro.sample('obs', dist.Normal(mean, sigma), obs=y)
return meanPyro中的推理Pyro中的模型评估三、常用类的介绍参考资料:pyro官方api文档参考^概率机器学习 http://mlg.eng.cam.ac.uk/zoubin/papers/NatureReprint15.pdf编辑于 2023-01-15 12:07・IP 属地北京概率编程API赞同 11 条评论分享喜欢收藏申请转载文章被以下专栏收录知识储备积累——数据科学篇本栏目资料来源于兴趣爱好,欢
Welcome to Pyro Examples and Tutorials! — Pyro Tutorials 编译 Pyro官方教程汉化0.0 documentation
Welcome to Pyro Examples and Tutorials! — Pyro Tutorials 编译 Pyro官方教程汉化0.0 documentation
Pyro官方教程汉化0.0
Introduction:
Pyro 模型介绍
Pyro 推断简介
SVI Part I: 随机变分推断基础
SVI Part II: 条件独立性,子采样和 Amortization
SVI Part III: ELBO 梯度估计
Pyro中随机函数的维度
Advanced:
离散潜变量模型
自定义 SVI 目标函数
Pyro 模型中使用 PyTorch JIT Compiler
Mini-Pyro
Poutine: Pyro 中使用 Effect Handlers 编程手册
Examples:
变分自编码器
贝叶斯回归简介(Part I)
贝叶斯回归推断算法(Part II)
深度马尔可夫模型
Attend Infer Repeat
半监督变分自编码器
随机波动率的 Levy 稳定分布模型
Contributed:
离散潜变量-高斯混合模型
高斯过程
高斯过程潜变量模型
贝叶斯优化
用 EasyGuide 构建 guides
Forecasting I: univariate, heavy tailed
Forecasting II: 状态空间模型
Forecasting III: 层级模型
跟踪未知数量的对象
Compiled Sequential 重要采样
理性言论行动框架
用 RSA 理解 Hyperbole
卡尔曼滤子
设计自适应实验以研究工作记忆
贝叶斯最优实验设计预测美国总统选举
Dirichlet 过程混合模型
Boosting 黑盒变分推断
Code Examples:
Capture-Recapture Models (CJS Models)
因果VAE
隐马尔可夫模型
LDA主题模型
Markov Chain Monte Carlo
NeuTraReparam
稀疏 Gamma 深度指数族分布
Deep Kernel Learning
Plated Einsum
多元预测
高斯过程时间序列模型
序贯蒙特卡洛滤波
Pyro Tutorials 编译
Docs »
Welcome to Pyro Examples and Tutorials!
View page source
Welcome to Pyro Examples and Tutorials!¶
— by Heyang Gong
Pyro 是一个 Deep Universal Probabilistic Programming, 将会是我们 Causal AI 的一个重要编程框架。这是一个 Pyro 教程的中文编译项目,我们的翻译一方面仅仅翻译部分内容使之尽量接近原来的官方教程,另外一方面会加入一些个人的总结的理解。
相关资料包括:
Pyro 官网
Pyro 全面介绍
Pyro 官方教程汉化版
需要注意:在本教程中,我们混用了随机函数,函数,分布,随机变量这几个概念,他们都是概率程序(probabilistic programs)的不同说法。
Causal AI: https://sites.google.com/view/minituring/
Introduction:
Pyro 模型介绍
初等随机函数
一个简单模型
pyro.sample 原语
通用概率编程
下一步?
Pyro 推断简介
随机函数的条件化
用指导分布近似后验
参数化分布和变分推断
例子完整代码
拆解成梯度下降法
下一步?
SVI Part I: 随机变分推断基础
SVI数学基础简介
指导分布
目标函数ELBO
SVI 类
optimizers
掷硬币例子
思考
SVI Part II: 条件独立性,子采样和 Amortization
条件独立声明
子采样
Amortization
变分自编码
SVI Part III: ELBO 梯度估计
数学背景
简单情况: 可重参数化
Tricky case: 不可重参数化
Reducing Variance via Dependency Structure
Reducing Variance with Data-Dependent Baselines
端对端 Baseline 例子
Pyro中随机函数的维度
随机函数的维度
plate内部张量子采样
广播和并行计算
Advanced:
离散潜变量模型
概览
Mechanics of enumeration
Plates and enumeration
时间序列示例
自定义 SVI 目标函数
SVI 的基本用法
修改损失函数
自定义 ELBO 损失函数
Pyro 模型中使用 PyTorch JIT Compiler
Introduction
A simple model
Varying structure
Mini-Pyro
Example use of mini-Pyro
Poutine: Pyro 中使用 Effect Handlers 编程手册
Introduction
Pyro 的算法构建基石库 Poutine
用 Messenger 构建新 EH
Messenger 类的方法详解
回顾和总结例子的处理
Mini-pyro 简介
用 effect handlers 实现推断算法实战
Examples:
变分自编码器
VAE 数学简介
VAE in Pyro
Inference
Code and Sample results
贝叶斯回归简介(Part I)
Setup
线性回归
使用 SVI 做贝叶斯回归
Model Evaluation
Model Serving via TorchScript
贝叶斯回归推断算法(Part II)
Model + Guide
SVI
HMC
Comparing Posterior Distributions
MultivariateNormal Guide
参考文献
深度马尔可夫模型
模型分布
指导分布
随机变分推断
Data Loading, Training, and Evaluation
Bells, whistles, and other improvements
Attend Infer Repeat
Multi-mnist 数据集的生成模型
模型分布
指导分布
Inference
Results
In practice
半监督变分自编码器
半监督VAE简介
推断中的挑战
思路一:标准目标函数,直接估计
思路二:标准目标函数,改进 estimator
思路三:改进目标函数
总结
Final thoughts
随机波动率的 Levy 稳定分布模型
Summary
Table of contents
Contributed:
离散潜变量-高斯混合模型
Overview
Training a MAP estimator
Serving the model: predicting membership
MCMC
高斯过程
数学理解
数据集
构建模型
模型推断和训练
稀疏高斯过程
高斯过程潜变量模型
Dataset
Modelling
Inference
Visualizing the result
Remarks
参考文献
贝叶斯优化
Problem Setup
目标函数
高斯过程先验
Define an acquisition function
The inner loop of Bayesian Optimization
Running the algorithm
用 EasyGuide 构建 guides
时间序列建模
用 EasyGuide 快速构建 guide
Amortized guides
Forecasting I: univariate, heavy tailed
Summary
Forecasting II: 状态空间模型
Intro to state space models
Gaussian HMM
Heavy-tailed modeling with Linear HMM
Forecasting III: 层级模型
Multivariate time series
Deeper hierarchical models
Subsampling
跟踪未知数量的对象
Generate data
Train
Compiled Sequential 重要采样
构建 model
构建 guide:
Create a CSIS instance:
参考文献
理性言论行动框架
用 RSA 理解 Hyperbole
Pragmatic Halo
Irony and More Complex Affect
卡尔曼滤子
Dynamic process
Kalman Update
Nonlinear Estimation: Extended Kalman Filter
参考文献
设计自适应实验以研究工作记忆
工作记忆模型
Inference in the model
Bayesian optimal experimental design
The adaptive experiment
Extensions
参考文献
贝叶斯最优实验设计预测美国总统选举
选择先验分布
Setting up the model
Measuring the expected information gain of a polling strategy
Running the experiment
Conclusions
参考文献
Dirichlet 过程混合模型
什么是贝叶斯非参数模型?
Inference
Criticism
参考文献
Boosting 黑盒变分推断
Theoretical Background
BBBVI in Pyro
The Complete Implementation
Code Examples:
Capture-Recapture Models (CJS Models)
因果VAE
隐马尔可夫模型
LDA主题模型
Markov Chain Monte Carlo
NeuTraReparam
稀疏 Gamma 深度指数族分布
Deep Kernel Learning
Plated Einsum
多元预测
高斯过程时间序列模型
序贯蒙特卡洛滤波
Indices and tables¶
Index
Module Index
Search Page
Next
© Copyright Uber Technologies, Inc; 编译 by Heyang Gong
Built with Sphinx using a theme provided by Read the Docs.
GitHub - pyro-ppl/pyro: Deep universal probabilistic programming with Python and PyTorch
GitHub - pyro-ppl/pyro: Deep universal probabilistic programming with Python and PyTorch
Skip to content
Toggle navigation
Sign in
Product
Actions
Automate any workflow
Packages
Host and manage packages
Security
Find and fix vulnerabilities
Codespaces
Instant dev environments
Copilot
Write better code with AI
Code review
Manage code changes
Issues
Plan and track work
Discussions
Collaborate outside of code
Explore
All features
Documentation
GitHub Skills
Blog
Solutions
For
Enterprise
Teams
Startups
Education
By Solution
CI/CD & Automation
DevOps
DevSecOps
Resources
Learning Pathways
White papers, Ebooks, Webinars
Customer Stories
Partners
Open Source
GitHub Sponsors
Fund open source developers
The ReadME Project
GitHub community articles
Repositories
Topics
Trending
Collections
Pricing
Search or jump to...
Search code, repositories, users, issues, pull requests...
Search
Clear
Search syntax tips
Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
Saved searches
Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our documentation.
Cancel
Create saved search
Sign in
Sign up
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
pyro-ppl
/
pyro
Public
Notifications
Fork
976
Star
8.3k
Deep universal probabilistic programming with Python and PyTorch
pyro.ai
License
Apache-2.0 license
8.3k
stars
976
forks
Branches
Tags
Activity
Star
Notifications
Code
Issues
225
Pull requests
26
Actions
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Wiki
Security
Insights
pyro-ppl/pyro
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
devBranchesTagsGo to fileCodeFolders and filesNameNameLast commit messageLast commit dateLatest commit History2,452 Commits.github.github dockerdocker docsdocs examplesexamples profilerprofiler pyropyro scriptsscripts teststests tutorialtutorial .codecov.yml.codecov.yml .coveragerc.coveragerc .gitattributes.gitattributes .gitignore.gitignore .readthedocs.yml.readthedocs.yml CODE_OF_CONDUCT.mdCODE_OF_CONDUCT.md CONTRIBUTING.mdCONTRIBUTING.md LICENSE.mdLICENSE.md MANIFEST.inMANIFEST.in MakefileMakefile README.mdREADME.md RELEASE-MANAGEMENT.mdRELEASE-MANAGEMENT.md pyproject.tomlpyproject.toml setup.cfgsetup.cfg setup.pysetup.py View all filesRepository files navigationREADMECode of conductApache-2.0 license
Getting Started |
Documentation |
Community |
Contributing
Pyro is a flexible, scalable deep probabilistic programming library built on PyTorch. Notably, it was designed with these principles in mind:
Universal: Pyro is a universal PPL - it can represent any computable probability distribution.
Scalable: Pyro scales to large data sets with little overhead compared to hand-written code.
Minimal: Pyro is agile and maintainable. It is implemented with a small core of powerful, composable abstractions.
Flexible: Pyro aims for automation when you want it, control when you need it. This is accomplished through high-level abstractions to express generative and inference models, while allowing experts easy-access to customize inference.
Pyro was originally developed at Uber AI and is now actively maintained by community contributors, including a dedicated team at the Broad Institute.
In 2019, Pyro became a project of the Linux Foundation, a neutral space for collaboration on open source software, open standards, open data, and open hardware.
For more information about the high level motivation for Pyro, check out our launch blog post.
For additional blog posts, check out work on experimental design and
time-to-event modeling in Pyro.
Installing
Installing a stable Pyro release
Install using pip:
pip install pyro-ppl
Install from source:
git clone git@github.com:pyro-ppl/pyro.git
cd pyro
git checkout master # master is pinned to the latest release
pip install .
Install with extra packages:
To install the dependencies required to run the probabilistic models included in the examples/tutorials directories, please use the following command:
pip install pyro-ppl[extras]
Make sure that the models come from the same release version of the Pyro source code as you have installed.
Installing Pyro dev branch
For recent features you can install Pyro from source.
Install Pyro using pip:
pip install git+https://github.com/pyro-ppl/pyro.git
or, with the extras dependency to run the probabilistic models included in the examples/tutorials directories:
pip install git+https://github.com/pyro-ppl/pyro.git#egg=project[extras]
Install Pyro from source:
git clone https://github.com/pyro-ppl/pyro
cd pyro
pip install . # pip install .[extras] for running models in examples/tutorials
Running Pyro from a Docker Container
Refer to the instructions here.
Citation
If you use Pyro, please consider citing:
@article{bingham2019pyro,
author = {Eli Bingham and
Jonathan P. Chen and
Martin Jankowiak and
Fritz Obermeyer and
Neeraj Pradhan and
Theofanis Karaletsos and
Rohit Singh and
Paul A. Szerlip and
Paul Horsfall and
Noah D. Goodman},
title = {Pyro: Deep Universal Probabilistic Programming},
journal = {J. Mach. Learn. Res.},
volume = {20},
pages = {28:1--28:6},
year = {2019},
url = {http://jmlr.org/papers/v20/18-403.html}
}
About
Deep universal probabilistic programming with Python and PyTorch
pyro.ai
Topics
python
machine-learning
deep-learning
pytorch
probabilistic-programming
bayesian
bayesian-inference
variational-inference
probabilistic-modeling
Resources
Readme
License
Apache-2.0 license
Code of conduct
Code of conduct
Activity
Custom properties
Stars
8.3k
stars
Watchers
204
watching
Forks
976
forks
Report repository
Releases
34
1.9.0
Latest
Feb 19, 2024
+ 33 releases
Sponsor this project
Sponsor
Learn more about GitHub Sponsors
Packages
0
No packages published
Contributors
151
+ 137 contributors
Languages
Python
99.3%
C++
0.2%
Makefile
0.2%
Shell
0.2%
TeX
0.1%
Dockerfile
0.0%
Footer
© 2024 GitHub, Inc.
Footer navigation
Terms
Privacy
Security
Status
Docs
Contact
Manage cookies
Do not share my personal information
You can’t perform that action at this time.
Getting Started With Pyro: Tutorials, How-to Guides and Examples — Pyro Tutorials 1.9.0 documentation
Getting Started With Pyro: Tutorials, How-to Guides and Examples — Pyro Tutorials 1.9.0 documentation
1.9.0
Introductory Tutorials
Introduction to Pyro
Automatic rendering of Pyro models
Rendering deterministic variables
SVI Part I: An Introduction to Stochastic Variational Inference in Pyro
SVI Part II: Conditional Independence, Subsampling, and Amortization
SVI Part III: ELBO Gradient Estimators
SVI Part IV: Tips and Tricks
Practical Pyro and PyTorch
Bayesian Regression - Introduction (Part 1)
Bayesian Regression - Inference Algorithms (Part 2)
Tensor shapes in Pyro
Modules in Pyro
High-dimensional Bayesian workflow, with applications to SARS-CoV-2 strains
Interactive posterior predictives checks
Using the PyTorch JIT Compiler with Pyro
Example: using vanilla PyTorch to perform optimization in SVI
Example: distributed training via Horovod
Example: distributed training via PyTorch Lightning
SVI with a Normalizing Flow guide
Deep Generative Models
Variational Autoencoders
The Semi-Supervised VAE
Conditional Variational Auto-encoder
Normalizing Flows - Introduction
Variational Autoencoder with a Normalizing Flow prior
Deep Markov Model
Attend Infer Repeat
Example: Causal Effect VAE
Example: Sparse Gamma Deep Exponential Family
Probabilistic Topic Modeling
scANVI: Deep Generative Modeling for Single Cell Data with Pyro
Discrete Latent Variables
Inference with Discrete Latent Variables
Gaussian Mixture Model
Dirichlet Process Mixture Models in Pyro
Example: Toy Mixture Model With Discrete Enumeration
Example: Hidden Markov Models
Example: Capture-Recapture Models (CJS Models)
Example: hierarchical mixed-effect hidden Markov models
Example: Discrete Factor Graph Inference with Plated Einsum
Example: Amortized Latent Dirichlet Allocation
Customizing Inference
MLE and MAP Estimation
Doing the same thing with AutoGuides
Writing guides using EasyGuide
Customizing SVI objectives and training loops
Boosting Black Box Variational Inference
Example: Neural MCMC with NeuTraReparam
Example: Sparse Bayesian Linear Regression
Example: reducing boilerplate with pyro.contrib.autoname
Application: Time Series
Forecasting I: univariate, heavy tailed
Forecasting II: state space models
Forecasting III: hierarchical models
Forecasting with Dynamic Linear Model (DLM)
Levy Stable models of Stochastic Volatility
Multivariate Forecasting
Example: Gaussian Process Time Series Models
Application: Gaussian Processes
Gaussian Processes
Gaussian Process Latent Variable Model
Bayesian Optimization
Example: Deep Kernel Learning
Application: Epidemiology
Epidemiological models: Introduction
Example: Univariate epidemiological models
Example: Regional epidemiological models
Example: Epidemiological inference via HMC
Logistic growth models of SARS-CoV-2 lineage proportions
Application: Biological sequences
Example: Constant + MuE (Profile HMM)
Example: Probabilistic PCA + MuE (FactorMuE)
Application: Experimental Design
Designing Adaptive Experiments to Study Working Memory
Predicting the outcome of a US presidential election using Bayesian optimal experimental design
Application: Object Tracking
Tracking an Unknown Number of Objects
Kalman Filter
Other Inference Algorithms
Example: analyzing baseball stats with MCMC
Example: Inference with Markov Chain Monte Carlo
Example: MCMC with an LKJ prior over covariances
Compiled Sequential Importance Sampling
Example: Sequential Monte Carlo Filtering
Example: importance sampling
The Rational Speech Act framework
Understanding Hyperbole using RSA
Example: Utilizing Predictive and Deterministic with MCMC and SVI
Understanding Pyro's Internals
Mini-Pyro
Poutine: A Guide to Programming with Effect Handlers in Pyro
pyro.contrib.funsor, a new backend for Pyro - New primitives (Part 1)
pyro.contrib.funsor, a new backend for Pyro - Building inference algorithms (Part 2)
Example: hidden Markov models with pyro.contrib.funsor and pyroapi
Deprecated
(DEPRECATED) An Introduction to Models in Pyro
(DEPRECATED) An Introduction to Inference in Pyro
Pyro Tutorials
»
Getting Started With Pyro: Tutorials, How-to Guides and Examples
View page source
Getting Started With Pyro: Tutorials, How-to Guides and Examples¶
Welcome! This page collects tutorials written by the Pyro community.
If you’re having trouble finding or understanding anything here,
please don’t hesitate to ask a question on our forum!
New users: getting from zero to one¶
If you’re new to probabilistic programming or variational inference,
you might want to start by reading the series Introductory Tutorials, especially the Introduction to Pyro.
If you’re new to PyTorch, you may also benefit from reading the official introduction “Deep Learning with PyTorch.”
After that, you’re ready to get started using Pyro! (Yes, really!)
Follow the instructions on the front page to install Pyro
and look carefully through the series Practical Pyro and PyTorch,
especially the first Bayesian regression tutorial.
This tutorial goes step-by-step through solving a simple Bayesian machine learning problem with Pyro,
grounding the concepts from the introductory tutorials in runnable code.
Users interested in integrating with existing PyTorch training and serving infrastructure should also read the PyroModule tutorial
and look at the SVI with PyTorch and SVI with Lightning examples.
Most users who reach this point will also find our guide to tensor shapes in Pyro essential reading.
Pyro makes extensive use of the behavior of “array broadcasting”
baked into PyTorch and other array libraries to parallelize models and inference algorithms,
and while it can be difficult to understand this behavior initially, applying the intuition and rules of thumb there
will go a long way toward making your experience smooth and avoiding nasty shape errors.
Core functionality: Deep learning, discrete variables and customizable inference¶
A basic familiarity with this introductory material is all you will need to dive right into exploiting Pyro’s two biggest strengths:
integration with deep learning and automated exact inference for discrete latent variables.
The former is described with numerous examples in the series Deep Generative Models.
All are elaborations on the basic idea of the variational autoencoder, introduced in great detail in the first tutorial of this series.
Pyro’s facility with discrete latent variable models like the hidden Markov model is surveyed in the series Discrete Latent Variables.
Making use of this in your own work will require careful reading of our overview and programming guide that opens this series.
Another feature of Pyro is its programmability, the subject of a series of tutorials in Customizing Inference.
Users working with large models where only part of the model needs special attention
may be interested in pyro.contrib.easyguide, introduced in the first tutorial of the series.
Meanwhile, machine learning researchers interested in developing variational inference algorithms may wish to peruse
the guide to implementing custom variational objectives,
and a companion example that walks through implementing “Boosting BBVI”.
Particularly enthusiastic users and potential contributors, especially those interested in contributing to Pyro’s core components,
may even be interested in how Pyro itself works under the hood, partially described in the series Understanding Pyro's Internals.
The mini-pyro example contains a complete and heavily commented implementation of a small version of the Pyro language in just a few hundred lines of code,
and should serve as a more digestable introduction to the real thing.
Tools for specific problems¶
Pyro is a mature piece of open-source software with “batteries included.”
In addition to the core machinery for modelling and inference,
it includes a large toolkit of dedicated domain- or problem-specific modelling functionality.
One particular area of strength is time-series modelling via pyro.contrib.forecasting,
a library for scaling hierarchical, fully Bayesian models of multivariate time series to thousands or millions of series and datapoints.
This is described in the series Application: Time Series.
Another area of strength is probabilistic machine learning with Gaussian processes.
pyro.contrib.gp, described in the series Application: Gaussian Processes,
is a library within Pyro implementing a variety of exact or approximate Gaussian process models compatible with Pyro’s inference engines.
Pyro is also fully compatible with GPyTorch, a dedicated library for scalable GPs,
as described in their Pyro example series.
List of Tutorials¶
Introductory Tutorials
Introduction to Pyro
Automatic rendering of Pyro models
Rendering deterministic variables
SVI Part I: An Introduction to Stochastic Variational Inference in Pyro
SVI Part II: Conditional Independence, Subsampling, and Amortization
SVI Part III: ELBO Gradient Estimators
SVI Part IV: Tips and Tricks
Practical Pyro and PyTorch
Bayesian Regression - Introduction (Part 1)
Bayesian Regression - Inference Algorithms (Part 2)
Tensor shapes in Pyro
Modules in Pyro
High-dimensional Bayesian workflow, with applications to SARS-CoV-2 strains
Interactive posterior predictives checks
Using the PyTorch JIT Compiler with Pyro
Example: using vanilla PyTorch to perform optimization in SVI
Example: distributed training via Horovod
Example: distributed training via PyTorch Lightning
SVI with a Normalizing Flow guide
Deep Generative Models
Variational Autoencoders
The Semi-Supervised VAE
Conditional Variational Auto-encoder
Normalizing Flows - Introduction
Variational Autoencoder with a Normalizing Flow prior
Deep Markov Model
Attend Infer Repeat
Example: Causal Effect VAE
Example: Sparse Gamma Deep Exponential Family
Probabilistic Topic Modeling
scANVI: Deep Generative Modeling for Single Cell Data with Pyro
Discrete Latent Variables
Inference with Discrete Latent Variables
Gaussian Mixture Model
Dirichlet Process Mixture Models in Pyro
Example: Toy Mixture Model With Discrete Enumeration
Example: Hidden Markov Models
Example: Capture-Recapture Models (CJS Models)
Example: hierarchical mixed-effect hidden Markov models
Example: Discrete Factor Graph Inference with Plated Einsum
Example: Amortized Latent Dirichlet Allocation
Customizing Inference
MLE and MAP Estimation
Doing the same thing with AutoGuides
Writing guides using EasyGuide
Customizing SVI objectives and training loops
Boosting Black Box Variational Inference
Example: Neural MCMC with NeuTraReparam
Example: Sparse Bayesian Linear Regression
Example: reducing boilerplate with pyro.contrib.autoname
Application: Time Series
Forecasting I: univariate, heavy tailed
Forecasting II: state space models
Forecasting III: hierarchical models
Forecasting with Dynamic Linear Model (DLM)
Levy Stable models of Stochastic Volatility
Multivariate Forecasting
Example: Gaussian Process Time Series Models
Application: Gaussian Processes
Gaussian Processes
Gaussian Process Latent Variable Model
Bayesian Optimization
Example: Deep Kernel Learning
Application: Epidemiology
Epidemiological models: Introduction
Example: Univariate epidemiological models
Example: Regional epidemiological models
Example: Epidemiological inference via HMC
Logistic growth models of SARS-CoV-2 lineage proportions
Application: Biological sequences
Example: Constant + MuE (Profile HMM)
Example: Probabilistic PCA + MuE (FactorMuE)
Application: Experimental Design
Designing Adaptive Experiments to Study Working Memory
Predicting the outcome of a US presidential election using Bayesian optimal experimental design
Application: Object Tracking
Tracking an Unknown Number of Objects
Kalman Filter
Other Inference Algorithms
Example: analyzing baseball stats with MCMC
Example: Inference with Markov Chain Monte Carlo
Example: MCMC with an LKJ prior over covariances
Compiled Sequential Importance Sampling
Example: Sequential Monte Carlo Filtering
Example: importance sampling
The Rational Speech Act framework
Understanding Hyperbole using RSA
Example: Utilizing Predictive and Deterministic with MCMC and SVI
Understanding Pyro's Internals
Mini-Pyro
Poutine: A Guide to Programming with Effect Handlers in Pyro
pyro.contrib.funsor, a new backend for Pyro - New primitives (Part 1)
pyro.contrib.funsor, a new backend for Pyro - Building inference algorithms (Part 2)
Example: hidden Markov models with pyro.contrib.funsor and pyroapi
Deprecated
(DEPRECATED) An Introduction to Models in Pyro
(DEPRECATED) An Introduction to Inference in Pyro
Indices and tables¶
Index
Module Index
Search Page
Next
© Copyright Pyro Contributors.
Built with Sphinx using a
theme
provided by Read the Docs.
[1810.09538] Pyro: Deep Universal Probabilistic Programming
[1810.09538] Pyro: Deep Universal Probabilistic Programming
Skip to main content
We gratefully acknowledge support from the Simons Foundation, member institutions, and all contributors. Donate
> cs > arXiv:1810.09538
Help | Advanced Search
All fields
Title
Author
Abstract
Comments
Journal reference
ACM classification
MSC classification
Report number
arXiv identifier
DOI
ORCID
arXiv author ID
Help pages
Full text
Search
open search
GO
open navigation menu
quick links
Login
Help Pages
About
Computer Science > Machine Learning
arXiv:1810.09538 (cs)
[Submitted on 18 Oct 2018]
Title:Pyro: Deep Universal Probabilistic Programming
Authors:Eli Bingham, Jonathan P. Chen, Martin Jankowiak, Fritz Obermeyer, Neeraj Pradhan, Theofanis Karaletsos, Rohit Singh, Paul Szerlip, Paul Horsfall, Noah D. Goodman Download a PDF of the paper titled Pyro: Deep Universal Probabilistic Programming, by Eli Bingham and 9 other authors
Download PDF
Abstract:Pyro is a probabilistic programming language built on Python as a platform for developing advanced probabilistic models in AI research. To scale to large datasets and high-dimensional models, Pyro uses stochastic variational inference algorithms and probability distributions built on top of PyTorch, a modern GPU-accelerated deep learning framework. To accommodate complex or model-specific algorithmic behavior, Pyro leverages Poutine, a library of composable building blocks for modifying the behavior of probabilistic programs.
Comments:
Submitted to JMLR MLOSS track
Subjects:
Machine Learning (cs.LG); Programming Languages (cs.PL); Machine Learning (stat.ML)
Cite as:
arXiv:1810.09538 [cs.LG]
(or
arXiv:1810.09538v1 [cs.LG] for this version)
https://doi.org/10.48550/arXiv.1810.09538
Focus to learn more
arXiv-issued DOI via DataCite
Submission history From: Eli Bingham [view email] [v1]
Thu, 18 Oct 2018 19:28:32 UTC (20 KB)
Full-text links:
Access Paper:
Download a PDF of the paper titled Pyro: Deep Universal Probabilistic Programming, by Eli Bingham and 9 other authorsDownload PDFTeX SourceOther Formats
view license
Current browse context: cs.LG
< prev
|
next >
new
|
recent
|
1810
Change to browse by:
cs
cs.PL
stat
stat.ML
References & Citations
NASA ADSGoogle Scholar
Semantic Scholar
DBLP - CS Bibliography
listing | bibtex
Eli BinghamJonathan P. ChenMartin JankowiakFritz ObermeyerNeeraj Pradhan …
a
export BibTeX citation
Loading...
BibTeX formatted citation
×
loading...
Data provided by:
Bookmark
Bibliographic Tools
Bibliographic and Citation Tools
Bibliographic Explorer Toggle
Bibliographic Explorer (What is the Explorer?)
Litmaps Toggle
Litmaps (What is Litmaps?)
scite.ai Toggle
scite Smart Citations (What are Smart Citations?)
Code, Data, Media
Code, Data and Media Associated with this Article
Links to Code Toggle
CatalyzeX Code Finder for Papers (What is CatalyzeX?)
DagsHub Toggle
DagsHub (What is DagsHub?)
GotitPub Toggle
Gotit.pub (What is GotitPub?)
Links to Code Toggle
Papers with Code (What is Papers with Code?)
ScienceCast Toggle
ScienceCast (What is ScienceCast?)
Demos
Demos
Replicate Toggle
Replicate (What is Replicate?)
Spaces Toggle
Hugging Face Spaces (What is Spaces?)
Spaces Toggle
TXYZ.AI (What is TXYZ.AI?)
Related Papers
Recommenders and Search Tools
Link to Influence Flower
Influence Flower (What are Influence Flowers?)
Connected Papers Toggle
Connected Papers (What is Connected Papers?)
Core recommender toggle
CORE Recommender (What is CORE?)
IArxiv recommender toggle
IArxiv Recommender
(What is IArxiv?)
Author
Venue
Institution
Topic
About arXivLabs
arXivLabs: experimental projects with community collaborators
arXivLabs is a framework that allows collaborators to develop and share new arXiv features directly on our website.
Both individuals and organizations that work with arXivLabs have embraced and accepted our values of openness, community, excellence, and user data privacy. arXiv is committed to these values and only works with partners that adhere to them.
Have an idea for a project that will add value for arXiv's community? Learn more about arXivLabs.
Which authors of this paper are endorsers? |
Disable MathJax (What is MathJax?)
About
Help
contact arXivClick here to contact arXiv
Contact
subscribe to arXiv mailingsClick here to subscribe
Subscribe
Copyright
Privacy Policy
Web Accessibility Assistance
arXiv Operational Status
Get status notifications via
or slack
PYRO - Chester Young/Castion - 单曲 - 网易云音乐
PYRO - Chester Young/Castion - 单曲 - 网易云音乐
生成外链播放器
PYRO
歌手:Chester Young / Castion
所属专辑:PYRO
播放
收藏
分享
下载
评论
包含这首歌的歌单
[蛋仔派对]超燃BGM/精彩击杀
by世天羽
蛋仔派对巅峰上分dj亲测有效
by小蓝总_
压迫感 | 游戏高燃、硬核卡点BGM
by尘不到_Zikk
相似歌曲
What You Want
Ilkay Sencan
Ass Like That
阿拉丁FM
Do It(Orginal Max)
DJ文樂/鸢北
My Songs Know What You Did In The Dark (Light Em Up)
Fall Out Boy
Black Magic
Jonasu
网易云音乐多端下载
iPhone
PC
Android
同步歌单,随时畅听好音乐
用户wiki
补充或修改歌曲资料
用户wiki任务中心
音乐开放平台
云村交易所
Amped Studio
X StudioAI歌手
用户认证
音乐交易平台
云推歌
赞赏
服务条款|
隐私政策|
儿童隐私政策|
版权投诉|
投资者关系|
广告合作
|
联系我们
廉正举报
不良信息举报邮箱: 51jubao@service.netease.com
客服热线:95163298
互联网宗教信息服务许可证:浙(2022)0000120
增值电信业务经营许可证:浙B2-20150198
粤B2-20090191-18 工业和信息化部备案管理系统网站
网易公司版权所有©1997-2024杭州乐读科技有限公司运营:浙网文[2021] 1186-054号
浙公网安备 33010802013307号
回到顶部
{if degrade}
手机号登录
注 册
微信登录
QQ登录
微博登录
网易邮箱账号登录
同意
《服务条款》
《隐私政策》
《儿童隐私政策》
{else}
手机号登录
注 册
微信登录
QQ登录
微博登录
网易邮箱账号登录
同意
《服务条款》
《隐私政策》
《儿童隐私政策》
扫码登录
二维码已失效
点击刷新
使用 网易云音乐APP 扫码登录
扫描成功
请在手机上确认登录
选择其他登录模式
{/if}
忘记密码?
短信登录
自动登录
获取验证码
密码登录
自动登录
登 录
< 其他登录方式
没有账号?免费注册 >
自动登录
忘记密码?
登 录
< 其他登录方式
{list suggests as item}
${item|escape}
{/list}
手机号:
密码:
密码不能包含空格
包含字母、数字、符号中至少两种
密码长度为8-20位
下一步
< 返回登录
云音乐将不再支持 腾讯微博 登录方式,请绑定手机号,以免后续无法使用该账号
你的手机号:+
为了安全,我们会给你发送短信验证码
验证码:
< 返回登录
云音乐将不再支持 腾讯微博 登录方式,请绑定手机号,以免后续无法使用该账号
你的手机号:+
为了安全,我们会给你发送短信验证码
输入要解绑的完整手机号,用于验证您的身份
下一步
< 返回登录
跳过 >
获取验证码
获取验证码
取一个昵称,让大家记住你
完成注册,开启云音乐
取一个昵称,让大家记住你
完成注册,开启云音乐
云音乐将不再支持 腾讯微博 登录方式,设置登录密码,以后可以使用手机号登录
你的手机号:+
设置密码后,可以直接用该手机号+密码登录
密码不能包含空格
包含字母、数字、符号中至少两种
密码长度为8-20位
跳过 >
如果你不是机器人输入验证码一定没问题!
账号或密码错误
确 定
取消
+86
{list countries as x}
${x.zh}
+${x.code}
{/list}
由于你在非受信任的设备上登录,需要进行短信验证()
通过短信验证身份
{list data as x}${x.t}{/list}
歌单名:
错误提示
可通过“收藏”将音乐添加到新歌单中
新 建
取 消
评论共0条评论
◆◆
后面还有0条评论,查看更多>
收起
评论 ()
{list beg..end as y}
{var x=xlist[y]}
{if !!x}
${escape(x.user.nickname)}
{if x.user.avatarDetail && x.user.avatarDetail.identityIconUrl}
{/if}
{if x.user.vipRights}
{if x.user.vipRights.redplus && x.user.vipRights.redplus.vipCode === 300 && x.user.vipRights.redplus.rights && x.user.vipRights.redplus.iconUrl}
{elseif x.user.vipRights.associator && x.user.vipRights.associator.rights && x.user.vipRights.redVipLevel}
{if x.user.vipRights.associator.iconUrl}
{elseif x.user.vipRights.redVipLevel == 1}
{if useNewVipIcon}
{else}
{/if}
{elseif x.user.vipRights.redVipLevel == 2}
{if useNewVipIcon}
{else}
{/if}
{elseif x.user.vipRights.redVipLevel == 3}
{if useNewVipIcon}
{else}
{/if}
{elseif x.user.vipRights.redVipLevel == 4}
{if useNewVipIcon}
{else}
{/if}
{elseif x.user.vipRights.redVipLevel == 5}
{if useNewVipIcon}
{else}
{/if}
{elseif x.user.vipRights.redVipLevel == 6}
{if useNewVipIcon}
{else}
{/if}
{elseif x.user.vipRights.redVipLevel == 7}
{if useNewVipIcon}
{else}
{/if}
{/if}
{elseif x.user.vipRights.musicPackage && x.user.vipRights.musicPackage.rights}
{if x.user.vipRights.musicPackage.iconUrl}
{else}
{/if}
{elseif x.user.vipRights.redVipAnnualCount >= 1}
{if useNewVipIcon}
{else}
{/if}
{elseif x.user.vipRights.associator && x.user.vipRights.associator.rights}
{if useNewVipIcon}
{else}
{/if}
{/if}
{/if}
{if !!x.beRepliedUser}
回复 ${escape(x.beRepliedUser.nickname)}
${getAuthIcon(x.beRepliedUser)}
{if x.beRepliedUser.vipRights}
{if x.beRepliedUser.vipRights.redplus && x.beRepliedUser.vipRights.redplus.vipCode === 300 && x.beRepliedUser.vipRights.redplus.rights && x.beRepliedUser.vipRights.redplus.iconUrl}
{elseif x.beRepliedUser.vipRights.associator && x.beRepliedUser.vipRights.associator.rights}
{if x.beRepliedUser.vipRights.redVipAnnualCount >= 1}
{if useNewVipIcon}
{else}
{/if}
{elseif x.beRepliedUser.vipRights.associator.iconUrl}
{else}
{if useNewVipIcon}
{else}
{/if}
{/if}
{elseif x.beRepliedUser.vipRights.musicPackage && x.beRepliedUser.vipRights.musicPackage.rights}
{if x.beRepliedUser.vipRights.musicPackage.iconUrl}
{else}
{/if}
{/if}
{/if}
{/if}
:${getRichText(escape(x.content),'s-fc7')}
{if !!x.expressionUrl}
{/if}
{if x.beReplied&&x.beReplied.length}
{var replied = x.beReplied[0]}
◆◆
{if (replied && replied.status>=0) && (replied.content || replied.expressionUrl)}
${replied.user.nickname}${getAuthIcon(replied.user)}
{if replied.user.vipRights}
{if replied.user.vipRights.redplus && replied.user.vipRights.redplus.vipCode === 300 && replied.user.vipRights.redplus.rights && replied.user.vipRights.redplus.iconUrl}
{elseif replied.user.vipRights.associator && replied.user.vipRights.associator.rights}
{if replied.user.vipRights.redVipAnnualCount >= 1}
{if useNewVipIcon}
{else}
{/if}
{elseif replied.user.vipRights.associator.iconUrl}
{else}
{if useNewVipIcon}
{else}
{/if}
{/if}
{elseif replied.user.vipRights.musicPackage && replied.user.vipRights.musicPackage.rights}
{if replied.user.vipRights.musicPackage.iconUrl}
{else}
{/if}
{/if}
{/if}
:${getRichText(escape(replied.content),'s-fc7')}
{if !!replied.expressionUrl}
{/if}
{else}
该评论已删除
{/if}
{/if}
${timeformat(x.time)}
{if x.topCommentId}音乐人置顶{/if}
{if canTop()&&GUser&&GUser.userId&&(GUser.userId==x.user.userId)}
{if x.topCommentId}解除置顶{else}置顶评论{/if}|
{/if}
{if GUser&&GUser.userId&&(GUser.userId==x.user.userId||GUser.userId==resUserId)}
删除|
{else}
删除|
{/if}
{if GAllowRejectComment}
{if hot||!x.isRemoveHotComment}
移除精彩评论|
{else}
已移除精彩评论|
{/if}
{/if}
{if !x.topCommentId}{if x.likedCount} (${getPlayCount(x.likedCount)}){/if}
|{/if}
回复
{/if}
{/list}
{list beg..end as y}
{var x=xlist[y]}
${escape(x.user.nickname)}
{if x.user.avatarDetail && x.user.avatarDetail.identityIconUrl}
{/if}
{if x.user.vipRights}
{if x.user.vipRights.redplus && x.user.vipRights.redplus.vipCode === 300 && x.user.vipRights.redplus.rights && x.user.vipRights.redplus.iconUrl}
{elseif x.user.vipRights.associator && x.user.vipRights.associator.rights}
{if x.user.vipRights.associator.iconUrl}
{elseif x.user.vipRights.redVipLevel == 1}
{elseif x.user.vipRights.redVipLevel == 2}
{elseif x.user.vipRights.redVipLevel == 3}
{elseif x.user.vipRights.redVipLevel == 4}
{elseif x.user.vipRights.redVipLevel == 5}
{elseif x.user.vipRights.redVipLevel == 6}
{elseif x.user.vipRights.redVipLevel == 7}
{/if}
{elseif x.user.vipRights.musicPackage && x.user.vipRights.musicPackage.rights}
{if x.user.vipRights.musicPackage.iconUrl}
{else}
{/if}
{/if}
{/if}
{if !!x.beRepliedUser}
回复 ${escape(x.beRepliedUser.nickname)}
${getAuthIcon(x.beRepliedUser)}
{if x.beRepliedUser.vipRights}
{if x.beRepliedUser.vipRights.redplus && x.beRepliedUser.vipRights.redplus.vipCode === 300 && x.beRepliedUser.vipRights.redplus.rights && x.beRepliedUser.vipRights.redplus.iconUrl}
{elseif x.beRepliedUser.vipRights.associator && x.beRepliedUser.vipRights.associator.rights}
{if x.beRepliedUser.vipRights.redVipAnnualCount >= 1}
{elseif x.beRepliedUser.vipRights.associator.iconUrl}
{else}
{/if}
{elseif x.beRepliedUser.vipRights.musicPackage && x.beRepliedUser.vipRights.musicPackage.rights}
{if x.beRepliedUser.vipRights.musicPackage.iconUrl}
{else}
{/if}
{/if}
{/if}
{/if}
:${getRichText(escape(x.content),'s-fc7')}
{if !!x.expressionUrl}
{/if}
{if x.beReplied&&x.beReplied.length}
{var replied = x.beReplied[0]}
◆◆
{if replied&&replied.content}
${replied.user.nickname}${getAuthIcon(replied.user)}
{if replied.user.vipRights}
{if replied.user.vipRights.redplus && replied.user.vipRights.redplus.vipCode === 300 && replied.user.vipRights.redplus.rights && replied.user.vipRights.redplus.iconUrl}
{elseif replied.user.vipRights.associator && replied.user.vipRights.associator.rights}
{if replied.user.vipRights.redVipAnnualCount >= 1}
{elseif replied.user.vipRights.associator.iconUrl}
{else}
{/if}
{elseif replied.user.vipRights.musicPackage && replied.user.vipRights.musicPackage.rights}
{if replied.user.vipRights.musicPackage.iconUrl}
{else}
{/if}
{/if}
{/if}
:${getRichText(escape(replied.content),'s-fc7')}
{else}
该评论已删除
{/if}
{/if}
${timeformat(x.time)}
{if GUser&&GUser.userId&&(GUser.userId==x.user.userId||GUser.userId==resUserId)}
删除|
{else}
删除|
{/if}
{if x.likedCount} (${getPlayCount(x.likedCount)}){/if}
|
回复
{/list}
评论
110/120
◆◆
◆◆
回复
110/120
回复
110/120
发送110/120
评论
110/120
发送
110/120
新歌单
加载中...
{list beg..end as y}
{var x=xlist[y]}
{if x.highQuality}{/if}
${escape(cutStr(x.name,40))}
${x.trackCount}首
{if x.trackCount+size>10000}歌单已满{/if}
{/list}
说点什么
140
转发
取消
歌曲同步完成
查看我的音乐
{if suggests.length == 0}
轻敲空格完成输入
{else}
选择最近@的人或直接输入
{/if}
{list suggests as suggest}
${suggest.nickname}
{/list}
{if receiver}
${receiver.nickname}×
{/if}
选择或输入好友昵称
{list users as user}
${user.nickname}
{/list}
{list users as user}
${user.nickname}
{/list}
分享给大家
私信分享
最多选择10位好友
140/140
分享
取消
同时分享到:
{macro listArtists(artists)}
{list artists as art}
${art.name|mark}
{/list}
{/macro}
搜“${keyword|cutStr}” 相关用户 >
{list result.order as index}
{var lst=result[index]}
{if !!lst&&!!lst.length}
{if index=="songs"}
单曲
{list lst as song}
${song.name|mark}-${listArtists(song.artists)}
{/list}
{elseif index=="artists"}
歌手
{list lst as artist}
${artist.name|mark}
{/list}
{elseif index=="albums"}
专辑
{list lst as album}
${album.name|mark}{if album.artist}-${album.artist.name|mark}{/if}
{/list}
{elseif index=="playlists"}
歌单
{list lst as playlist}
${playlist.name|mark}
{/list}
{elseif index=="mvs"}
视频
{list lst as mv}
MV:${mv.name|mark}{if mv.artistName}-${mv.artistName|mark}{/if}
{/list}
{/if}
{/if}
{/list}
${info|escape}
{if canChange}{/if}
${title}
{if !fail}
{else}
${fail}
{/if}
{if !fail}
{else}
${fail}
{/if}
知道了
上传节目
删除
取消
服务条款和隐私政策更新
服务条款
同意
{list buttons as item}
${item.text}
{/list}
微信
易信
QQ空间
LOFTER
message
知道了
新浪微博
腾讯微博
豆瓣
140
分享
取消
${tip}
${oktext}
${cctext}
${tip}
${oktext}
{if showSongText}${songTxt}{/if}
${tip}
{if typeof(oktext) != 'undefined'}${oktext}{/if}
{if typeof(cctext) != 'undefined'}${cctext}{/if}
${tip}
{if typeof(oktext) != 'undefined'}${oktext}{/if}
{if typeof(cctext) != 'undefined'}${cctext}{/if}
该资源为公益歌曲
捐赠任意金额(2~4999元)即可无限畅听下载
新浪微博
微信
易信好友
QQ空间
LOFTER
豆瓣
悬赏1积分让大家来帮你补歌词,是否继续?
若30天内歌词未补充,积分将退还给您
继续求
取消
原手机号已停用
(使用其他方式验证)
原手机号仍能使用
(使用手机验证码验证)
{if hasWx}
点击使用微信验证
{/if}
{if hasQQ}
点击使用QQ验证
{/if}
请填写以下安全问题的答案
问题:
回答:
账号或密码错误
上一步
下一步
-请选择-
deepin15(64位)
ubuntu18.04(64位)
您的系统为Windows 10,推荐下载UWP版
下载UWP版本
继续下载PC版本
{list options as o}
${o|filter}
{/list}
使用云音乐客户端
即可无限下载高品质音乐
Mac版V1.9.1
PC版V1.9.1
已安装PC版
扫描下载手机版
该资源为付费内容,扫描下方二维码,使用最新的安卓或iPhone版本购买后即可畅享
{var title=""}
{if artists && artists.length}
{list artists as x}
{if x}
{var title = title + x.name}
{if x_index < x_length - 1}
{var title = title + " / "}
{/if}
{/if}
{/list}
{/if}
${escape(title)}
{if artists && artists.length}
{list artists as x}
{if !!x}
{if !!x.id}
${mark(escape(x.name))}
{else}
${mark(escape(x.name))}
{/if}
{if x_index < x_length - 1} / {/if}
{/if}
{/list}
{/if}
${comJST('com-mv-artists', artists, clazz, mark, boxClazz)}
{if x.userType==4}${before}${after}{elseif x.authStatus==1}${before}${after}{elseif (x.expertTags && x.expertTags.length>0) || !isEmptyObject(x.experts)}${before}${after}{/if}
{if loginUserProfile.avatarDetail&&loginUserProfile.avatarDetail.identityIconUrl}
{/if}
{if x.avatarDetail && x.avatarDetail.identityIconUrl}
{/if}
1/2
{list plist as item}
{/list}
{list beg..end as y}
{var x=xlist[y]}
${y+1}
{if type=='rank'}
{if x.lastRank>=0}
{if y-x.lastRank>0}
${y-x.lastRank}
{elseif y-x.lastRank==0}
0
{else}
${x.lastRank-y}
{/if}
{else}
{/if}
{/if}
{var alia=songAlia(x)}
${soil(x.name)}{if alia} - (${soil(alia)}){/if}
{if x.mvid>0}
MV
{/if}
${dur2time(x.duration/1000)}{if x.ftype==2}{/if}
分享
{if canDel}
删除
{/if}
${getArtistName(x.artists, '', '', false, false, true)}
{if type=='dayRcmd'}
{if x.album}${x.album.name}{/if}
不感兴趣
{else}
{if x.album}
${soil(x.album.name)}
{/if}
{/if}
{/list}
歌曲标题
时长
歌手
{list beg..end as y}
{var x=xlist[y]}
${y+1}
{if type=='rank'}
{if x.lastRank>=0}
{if y-x.lastRank>0}
${y-x.lastRank}
{elseif y-x.lastRank==0}
0
{else}
${x.lastRank-y}
{/if}
{else}
{/if}
{/if}
{if x.privilege.fee == 1}
{var alia=songAlia(x)}
${soil(x.name)}{if alia} - (${soil(alia)}){/if}
{if x.mvid>0}
MV
{/if}
{else}
{var alia=songAlia(x)}
${soil(x.name)}{if alia} - (${soil(alia)}){/if}
{if x.mvid>0}
MV
{/if}
{/if}
${dur2time(x.duration/1000)}{if x.ftype==2}{/if}
分享
{if canDel}
删除
{/if}
${getArtistName(x.artists, '', '/', false, true, true)}
{/list}
{list beg..end as y}
{var x=xlist[y]}
${y+1}
{var alia=songAlia(x)}
${soil(x.name)}{if alia} - (${soil(alia)}){/if}
{if x.mvid>0}
MV
{/if}
${dur2time(x.duration/1000)}{if x.ftype==2}{/if}
分享
{if canDel}
删除
{/if}
{if x.album}
{var transName = x.album.tns && x.album.tns.length > 0 ? x.album.tns[0] : ''}
${soil(x.album.name)}
{if transName}
- (${transName|escape})
{/if}
{/if}
{/list}
标题
时长
歌手
{list beg..end as y}
{var x=xlist[y]}
{if y<3}
${y+1}
{if x.lastRank>=0}
{if y-x.lastRank>0}
${y-x.lastRank}
{elseif y-x.lastRank==0}
0
{else}
${x.lastRank-y}
{/if}
{else}
{/if}
{if x.album}{/if}
{var alia=songAlia(x)}
${soil(x.name)}{if alia} - (${soil(alia)}){/if}
{if x.mvid>0}
MV
{/if}
{else}
${y+1}
{if x.lastRank>=0}
{if y-x.lastRank>0}
${y-x.lastRank}
{elseif y-x.lastRank==0}
0
{else}
${x.lastRank-y}
{/if}
{else}
{/if}
{var alia=songAlia(x)}
${soil(x.name)}{if alia} - (${soil(alia)}){/if}
{if x.mvid>0}
MV
{/if}
{/if}
${dur2time(x.duration/1000)}{if x.ftype==2}{/if}
分享
{if canDel}
删除
{/if}
${getArtistName(x.artists, '', '', false, false, true)}
{/list}
{list beg..end as y}
{var x=xlist[y]}
${y+1}
{var alia=songAlia(x)}
${soil(x.name)}{if alia} - (${soil(alia)}){/if}
{if x.mvid>0}
MV
{/if}
${dur2time(x.duration/1000)}{if x.ftype==2}{/if}
分享
{if canDel}
删除
{/if}
${getArtistName(x.artists, '', '', false, false, true)}
{if x.album}
${soil(x.album.name)}
{/if}
{/list}
{list beg..end as y}
{var x=xlist[y]}
{if extData&&extData.limit&&y>=extData.limit}
{break}
{/if}
{var from=getFrom()}
${y+1}.
${x.name}
-
${getArtistName(x.artists, 's-fc8')}
分享
下载
{if extData.showCount&&x.playCount}${x.playCount}次{/if}
{/list}
{if extData&&extData.limit&&xlist.length>extData.limit}
查看更多>
{/if}
{list beg..end as y}
{var x=xlist[y]}
${y+1}
{if type=='rank'}
{if x.lastRank>=0}
{if y-x.lastRank>0}
${y-x.lastRank}
{elseif y-x.lastRank==0}
0
{else}
${x.lastRank-y}
{/if}
{else}
{/if}
{/if}
{var alia=songAlia(x)}
${soil(x.name)}{if alia} - (${soil(alia)}){/if}
{if x.mvid>0}
MV
{/if}
分享
{if canDel}
删除
{/if}
${getArtistName(x.artists, '', '', false, false, true)}
{if x.album}
${soil(x.album.name)}
{/if}
${formatTime(x.paidTime)}
{/list}
最多选择10位好友
发 给:
内 容:
{if nolyric}
纯音乐,无歌词
{if thirdCopy}
${copyFrom}
{/if}
{elseif !lines.length}
暂时没有歌词 求歌词
{if thirdCopy}
${copyFrom}
{/if}
{else}
{list lines as l}
{if lines.length >limit && l_index==limit}
{/if}
${l.lyric}
{if lines.length > limit && l_index==lines.length-1}
展开
{/if}
{/list}
{/if}
{if !nolyric}
{if sgc}
上传歌词
{/if}
{if lrc&&lrc.lyric&&sfy}
翻译歌词
{/if}
{/if}
{if !(lrc&&lrc.lyric)}歌曲{/if}报错
{if !nolyric}
{if lyricUser&&lyricUser.userid}
贡献滚动歌词:${lyricUser.nickname}
{/if}
{if lyricUser&&lyricUser.userid==0}
贡献滚动歌词:${lyricUser.nickname}
{/if}
{if transUser&&transUser.userid}
贡献翻译:${transUser.nickname}
{/if}
{if transUser&&transUser.userid==0}
贡献翻译:${transUser.nickname}
{/if}
{if lrc&&lrc.lyric&&qfy}
暂时没有翻译,求翻译
{/if}
{/if}
{if degrade}
手机号登录
注 册
微信登录
QQ登录
微博登录
网易邮箱账号登录
同意
《服务条款》
《隐私政策》
《儿童隐私政策》
{else}
手机号登录
注 册
微信登录
QQ登录
微博登录
网易邮箱账号登录
同意
《服务条款》
《隐私政策》
《儿童隐私政策》
扫码登录
二维码已失效
点击刷新
使用 网易云音乐APP 扫码登录
扫描成功
请在手机上确认登录
选择其他登录模式
{/if}
忘记密码?
短信登录
自动登录
获取验证码
密码登录
自动登录
登 录
< 其他登录方式
没有账号?免费注册 >
自动登录
忘记密码?
登 录
< 其他登录方式
{list suggests as item}
${item|escape}
{/list}
手机号:
密码:
密码不能包含空格
包含字母、数字、符号中至少两种
密码长度为8-20位
下一步
< 返回登录
云音乐将不再支持 腾讯微博 登录方式,请绑定手机号,以免后续无法使用该账号
你的手机号:+
为了安全,我们会给你发送短信验证码
验证码:
< 返回登录
云音乐将不再支持 腾讯微博 登录方式,请绑定手机号,以免后续无法使用该账号
你的手机号:+
为了安全,我们会给你发送短信验证码
输入要解绑的完整手机号,用于验证您的身份
下一步
< 返回登录
跳过 >
获取验证码
获取验证码
取一个昵称,让大家记住你
完成注册,开启云音乐
取一个昵称,让大家记住你
完成注册,开启云音乐
云音乐将不再支持 腾讯微博 登录方式,设置登录密码,以后可以使用手机号登录
你的手机号:+
设置密码后,可以直接用该手机号+密码登录
密码不能包含空格
包含字母、数字、符号中至少两种
密码长度为8-20位
跳过 >
如果你不是机器人输入验证码一定没问题!
账号或密码错误
确 定
取消
+86
{list countries as x}
${x.zh}
+${x.code}
{/list}
由于你在非受信任的设备上登录,需要进行短信验证()
通过短信验证身份
Pyro - Python Remote Objects - 4.82 — Pyro 4.82 documentation
Pyro - Python Remote Objects - 4.82 — Pyro 4.82 documentation
Pyro
stable
Contents of this manual:
Intro and Example
Installing Pyro
Tutorial
Command line tools
Clients: Calling remote objects
Servers: hosting Pyro objects
Name Server
Security
Exceptions and remote tracebacks
Flame: Foreign Location Automatic Module Exposer
Tips & Tricks
Configuring Pyro
Pyro4 library API
Running on alternative Python implementations
Pyrolite - client library for Java and .NET
Change Log
Software License and Disclaimer
Pyro
Docs »
Pyro - Python Remote Objects - 4.82
Edit on GitHub
Pyro - Python Remote Objects - 4.82¶
What is Pyro?¶
It is a library that enables you to build applications in which
objects can talk to each other over the network, with minimal programming effort.
You can just use normal Python method calls to call objects on other machines.
Pyro is a pure Python library and runs on many different platforms and Python versions.
Pyro is copyright © Irmen de Jong (irmen@razorvine.net | http://www.razorvine.net). Please read Software License and Disclaimer.
It’s on Pypi as Pyro4. Source on Github: https://github.com/irmen/Pyro4
and version 5 as Pyro5 (Source)
Pyro4 is considered feature complete and new development is frozen.
Only very important bug fixes (such as security issues) will still be made to Pyro4.
New development, improvements and new features will only be available in its successor
Pyro5 . New code should use Pyro5 unless a feature
of Pyro4 is strictly required. Older code should consider migrating to Pyro5. It provides
a (simple) backwards compatibility api layer to make the porting easier.
Contents of this manual:
Intro and Example
About Pyro: feature overview
What can you use Pyro for?
Simple Example
Performance
Installing Pyro
Pyro5
Compatibility
Obtaining and installing Pyro
Third party libraries that Pyro4 uses
Stuff you get extra in the source distribution archive and not with packaged versions
Tutorial
Warm-up
Pyro concepts and tools
Building a Warehouse
Building a Stock market simulator
Other means of creating connections
Ok, what’s next?
Command line tools
Test echo server
Configuration check
Clients: Calling remote objects
Object discovery
Calling methods
Accessing remote attributes
Serialization
Proxies, connections, threads and cleaning up
Oneway calls
Batched calls
Remote iterators/generators
Asynchronous (‘future’) remote calls & call chains
Pyro Callbacks
Miscellaneous features
Servers: hosting Pyro objects
Creating a Pyro class and exposing its methods and properties
Exposing classes and methods without changing existing source code
Pyro Daemon: publishing Pyro objects
Controlling Instance modes and Instance creation
Autoproxying
Server types and Concurrency model
Serialization
Other features
Name Server
Starting the Name Server
Starting the Name Server from within your own code
Configuration items
Name server control tool
Locating the Name Server and using it in your code
The PYRONAME protocol type
The PYROMETA protocol type
Resolving object names
Registering object names
Free connections to the NS quickly
Using the name server with pickle, cloudpickle or dill serializers
Yellow-pages ability of the Name Server (metadata tags)
Other methods in the Name Server API
Security
Pickle, cloudpickle and dill as serialization formats (optional)
Network interface binding
Running Pyro servers with different credentials/user id
Secure communication via SSL/TLS
Dotted names (object traversal)
Environment variables overriding config items
Preventing arbitrary connections
Exceptions and remote tracebacks
Pyro exceptions
Remote exceptions
Detailed traceback information
Flame: Foreign Location Automatic Module Exposer
Enabling Flame
Command line server
Flame object and examples
Tips & Tricks
Best practices
Logging
Multiple network interfaces
Same major Python version required when using pickle, cloudpickle, dill or marshal
Wire protocol version
Asynchronous (‘future’) normal function calls
DNS setup
Pyro behind a NAT router/firewall
‘Failed to locate the nameserver’ or ‘Connection refused’ error, what now?
Binary data transfer / file transfer
MSG_WAITALL socket option
IPV6 support
Pyro and Numpy
Pyro via HTTP and JSON
Client information on the current_context, correlation id
Automatically freeing resources when client connection gets closed
Message annotations
Connection handshake
Efficient dispatchers or gateways that don’t de/reserialize messages
Hooking onto existing connected sockets such as from socketpair()
Configuring Pyro
Resetting the config to default values
Inspecting current config
Overview of Config Items
Pyro4 library API
Pyro4 — Main API package
Pyro4.core — core Pyro logic
Pyro4.naming — Pyro name server
Pyro4.util — Utilities and serializers
Pyro4.socketutil — Socket related utilities
Pyro4.message — Pyro wire protocol message
Pyro4.constants — Constant value definitions
Pyro4.config — Configuration items
Pyro4.errors — Exception classes
Pyro4.test.echoserver — Built-in echo server for testing purposes
Pyro4.utils.flame — Foreign Location Automatic Module Exposer
Pyro4.futures — asynchronous calls
Socket server API contract
Running on alternative Python implementations
IronPython
Pypy
Pyrolite - client library for Java and .NET
Change Log
Software License and Disclaimer
Indices and tables¶
Index
Search Page
Next
© Copyright Irmen de Jong
Revision 40336cb0.
Built with Sphinx using a theme provided by Read the Docs.
Read the Docs
v: stable
Versions
latest
stable
Downloads
html
epub
On Read the Docs
Project Home
Builds
Free document hosting provided by Read the Docs.