[ad_1]
Is there a straightforward way to sample from a multivariate normal distribution in PyTorch and only keep the samples that are in a defined low-probability region (e.g. P(x) < 5 %)?
Concrete example:
I have a batch of representation tensors as an output of a ResNet with a size of (batch_size, feature_size)
.
I can then generate the mean vector prototype
with size = (1, feature_size)
of those representations, and the corresponding empirical cov
matrix with size = (feature_size, feature_size)
. From my understanding I can use PyTorchs distributions
package to sample from the multivariate normal distribution, defined by prototype
and cov
like so:
from torch.distributions.multivariate_normal import MultivariateNormal
import torch.nn as nn
dist = MultivariateNormal(prototype, covariance_matrix = cov)
samples = dist.sample(torch.Size([10000]))
I’d like to know how to determine the probability region that a sample belongs to, i.e., I only want to keep samples with low probability. I am aware that there is dist.log_prob(value)
. However, I’m having a hard time gaining an intuition from that. The outputs don’t seem to make a lot of sense, as they are in the hundreds or thousands. Any idea what I’m missing here?
Thanks for your help.
[ad_2]