Skip to content

Resolving Must provide inverse transform to be able to sample from prior #2656

Closed Answered by Hrovatin
Hrovatin asked this question in Q&A
Discussion options

You must be logged in to vote

I resolved it as follows:

Define closure that is able to use samples from LKJCovariancePrior to set parameters of IndexKernel. I did not find an exact way to solve the equation for decomposing sampled cov matrix into kernel parameters, so I used gradient-based solver.

def set_index_kernel(index_kernel,cov):

    # Find kernel parameters from cov
    
    var_transform=torch.nn.functional.softplus
    cov=torch.detach(cov)
    def loss_fn(x, y):
        cov_pred= x @ x.transpose(-1,-2) + torch.diag_embed(var_transform(y))
        return torch.square(cov - cov_pred).sum()
    
    # Initial guess for the variables as tensors
    x = torch.randn_like(index_kernel.covar_factor,requires_grad=T…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Hrovatin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants