admin 管理员组文章数量: 1086019
I am working on TF Probability tutorials and working on a 2D grid approximation for mu, sigma of Normal distribution. I am trying to understand to what level I should expect broadcasting to work for the following code:
import tensorflow as tf
import tensorflow_probability as tfp
tfd = tfp.distributions
mu_list = tf.linspace(start=150, stop=160, num=100)
sigma_list = tf.linspace(start=7, stop=9, num=100)
mesh = tf.meshgrid(mu_list, sigma_list)
mu = tf.cast(tf.reshape(mesh[0], -1), tf.float32)
sig = tf.cast(tf.reshape(mesh[1], -1), tf.float32)
dists = tfd.Normal(loc=mu, scale=sig)
heights = tfd.Normal(loc=150, scale=20).sample(352)
dists.prob(heights)
This fails with
Incompatible shapes: [352] vs. [10000]
I am pretty sure I can solve this with either a tf.map_fn or a tf.vectorized_map operation, but curious if it is possible to generate a [10000, 352] shape tensor in the .prob/.log_prob call.
本文标签: Tensorflow Probability Normal Distribution logprob Incompatible shapesStack Overflow
版权声明:本文标题:Tensorflow Probability: Normal Distribution: log_prob Incompatible shapes - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744078567a2529808.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论