I know I can use gradient descent to infer input [parameters] of a neural network model but for some reason I need to infer those parameters via MCMC. To give you more context, the input has low number of parameters (e.g. 10) and they do not come from a specific distribution (e.g. Gaussian, Uniform etc) but are bounded in [0, 1]. During test time, the neural network model produces an image given an input. My goal is to infer the input parameters conditioned on an output. I am pretty new to Pyro and MCMC but I looked at an example here but cannot figure out how to translate what the example is doing to my problem because
pyro.sample seems to require using a specific distribution (maybe I can assume Uniform for my parameters?) and also SVI is used in that example and not MCMC. In addition, the VAE model used in the example has a definition that is different that the model I am using and I’m not sure how to modify the example to make it work in my case. So I wonder, how can I condition my model on an [expected] output and infer the input parameters of my model using Pyro and via MCMC?
Here’s a simplified version of the neural network model I’m using:
class model(nn.Module): def __init__(self): super(model, self).__init__() . . # define model layers . def forward(self, x): . . # do transposed convolutional operations on x and get predicted_means, predicted_sigma and reconsted_image . elbo = torch.sum(Normal(predicted_means, predicted_sigma).log_prob(reconsted_image), dim=[1,2,3]) return elbo def reconstruct(self, x): # This is the function I use during test time and MCMC needs to use this function . . # do transposed convolutional operations on x and get mu . return torch.clamp(mu, 0, 1)