简体   繁体   English

相当于`tensorflow_probability.edward2`中的`ed.copy`

[英]Equivalent of `ed.copy` in `tensorflow_probability.edward2`

I am trying to change my code from edward to tensorflow_probability.edward2 .我正在尝试将我的代码从edward更改为tensorflow_probability.edward2 The issue is that, whenever I define a posterior distribution, I use a_post = ed.copy(a, {u: qu}, scope='a_post') but .copy API seems no longer available:问题是,每当我定义后验分布时,我都会使用a_post = ed.copy(a, {u: qu}, scope='a_post').copy API 似乎不再可用:

module 'tensorflow_probability.python.edward2' has no attribute 'copy'

What's the tensorflow_probability way of doing the same operation?执行相同操作的tensorflow_probability方式是什么?

In edward, copy depended on unsupported TF graph-walking and copying.在 edward 中,复制依赖于不受支持的 TF 图遍历和复制。 In edward2, the approach is based on tracing, using 'interceptors'.在 edward2 中,该方法基于跟踪,使用“拦截器”。 Check out https://github.com/tensorflow/probability/blob/master/tensorflow_probability/examples/deep_exponential_family.py for an example of VI using the 'tape' interceptor.查看https://github.com/tensorflow/probability/blob/master/tensorflow_probability/examples/deep_exponential_family.py以获取使用“磁带”拦截器的 VI 示例。

Update: this one might be a simpler and/or more familiar (LDA) example: https://github.com/tensorflow/probability/blob/master/tensorflow_probability/examples/latent_dirichlet_allocation_edward2.py更新:这可能是一个更简单和/或更熟悉(LDA)的例子: https : //github.com/tensorflow/probability/blob/master/tensorflow_probability/examples/latent_dirichlet_allocation_edward2.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM