I am buliding a VAE model with pyro, the input data is a uniform distribution(0,1).
But I don’t know how to write the parameter in the
dist.Uniform()
of the
pyro.sample("obs", dist.Uniform().to_event(1), obs=x)
in the def model
because it need low and high parameters, I only have one loc_img
Here is my code
def model(self, x):
# register PyTorch module `decoder` with Pyro
pyro.module("decoder", self.decoder)
with pyro.plate("data", x.shape[0]):
# setup hyperparameters for prior p(z)
z_loc = x.new_zeros(torch.Size((x.shape[0], self.z_dim)))
z_scale = x.new_ones(torch.Size((x.shape[0], self.z_dim)))
# sample from prior (value will be sampled by guide when computing the ELBO)
z = pyro.sample("latent", dist.Normal(z_loc, z_scale).to_event(1))
# decode the latent code z
loc_img = self.decoder(z)
# score against actual images
pyro.sample("obs", dist.Uniform(...,...).to_event(1), obs=x)