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
Consider a B x d array of zs, where a row corresponds to one sample of a d-dimensional latent variable, and we have a mini-batch of size B.
Univariate Distributions
For mean-field methods, we'd like to do something like call bernoulli.logpmf(zs[:, i], p), where p is a scalar in [0,1]. This returns a B-dimensional vector,
For a univariate distribution, it takes a B-dimensional input and returns a B-dimensional output.
Multivariate Distributions
Consider a d-dimensional multivariate Gaussian. We call multivariate_normal.logpdf(zs.transpose(), mu, Sigma), where mu is d-dimensional, Sigma is d x d, and it returns a B-dimensional vector
Higher-dimensional arguments
We can also consider something like bernoulli.logpmf(zs[:, i], ps), where not only is zs[:, i] a M-dimensional vector but ps is also a M-dimensional vector (in [0,1]^d). I propose not doing this. This is bound to lead to bugs. Any time this comes up, I propose we do individual calls, bernoulli.logpmf(zs[1, i], ps[i]) and so on.
(I don't know a situation where this comes up enough that vectorizing this computation is crucial. If we notice this we can make the change. I don't think SciPy allows this either.)
The text was updated successfully, but these errors were encountered:
Consider a
B x d
array ofzs
, where a row corresponds to one sample of ad
-dimensional latent variable, and we have a mini-batch of sizeB
.Univariate Distributions
For mean-field methods, we'd like to do something like call
bernoulli.logpmf(zs[:, i], p)
, wherep
is a scalar in [0,1]. This returns aB
-dimensional vector,[ log Bernoulli(zs[1, i] | p), ..., log Bernoulli(zs[B, i] | p) ]^T
For a univariate distribution, it takes a
B
-dimensional input and returns aB
-dimensional output.Multivariate Distributions
Consider a
d
-dimensional multivariate Gaussian. We callmultivariate_normal.logpdf(zs.transpose(), mu, Sigma)
, wheremu
is d-dimensional,Sigma
is d x d, and it returns aB
-dimensional vector[ log Normal(zs[1, :] | mu, Sigma), ..., log Normal(zs[B, :] | mu, Sigma) ]^T
For a
d
-dimensional distribution, it takes aB x d
matrix of inputs and returns aB
-dimensional output.SciPy does this too!
Higher-dimensional arguments
We can also consider something like
bernoulli.logpmf(zs[:, i], ps)
, where not only iszs[:, i]
a M-dimensional vector butps
is also aM
-dimensional vector (in [0,1]^d). I propose not doing this. This is bound to lead to bugs. Any time this comes up, I propose we do individual calls,bernoulli.logpmf(zs[1, i], ps[i])
and so on.(I don't know a situation where this comes up enough that vectorizing this computation is crucial. If we notice this we can make the change. I don't think SciPy allows this either.)
The text was updated successfully, but these errors were encountered: