cornellius-gp / gpytorch

A highly efficient implementation of Gaussian Processes in PyTorch
MIT License
3.57k stars 560 forks source link

[Question] Multitask Hadamard with batched variational inference #2043

Open irinaespejo opened 2 years ago

irinaespejo commented 2 years ago

Hello team :wave:

I've looked around the documentation examples and issues to implement a Multitask GP Regression like this one but the dataset is pretty large so I would like to also implement SVGR like in this example.

I have checked this other example but my main problem is that the input data is irregular. Meaning that for every input point I only have one evaluation of one task. I have also checked other issues like #1743 , #1433 , #1285 and #657 but found no conclusive answer (I am a bit lost with all these issues)

More precisely I have:

Does GPyTorch support this type of model in a way that is not super hacky?

Thank you so much! :slightly_smiling_face:

gpleiss commented 2 years ago

Hi @irinaespejo check out this section of the multitask SVGP tutorial: https://docs.gpytorch.ai/en/latest/examples/04_Variational_and_Approximate_GPs/SVGP_Multitask_GP_Regression.html#Output-modes

You'd do something like this:

task_indices = torch.cat([torch.zeros(n_1, dtype=torch.long), torch.ones(n_2, dtype=torch.long)])  # an index tensor that is [0, ..., 0, 1, ..., 1], that will assign each input to its respective task
model(torch.cat([x_1, x_2], dim=-2), task_indices=task_indices)  # outputs a multivariate normal of size n_1 + n_2