简体   繁体   中英

Equivalent of `ed.copy` in `tensorflow_probability.edward2`

I am trying to change my code from edward to 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:

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

What's the tensorflow_probability way of doing the same operation?

In edward, copy depended on unsupported TF graph-walking and copying. In edward2, the approach is based on tracing, using 'interceptors'. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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