SVGP Classification reference #1658
-
Hi, For a multi-class classification task, if I follow the tutorial of Variational GPs w/ Multiple Outputs and replace the X, y = make_blobs(n_samples=30, centers=num_groups, n_features=2, random_state=0)
X = torch.tensor(X, dtype=torch.float32)
y = torch.tensor(y, dtype=torch.int64)
class GPClassifier(ApproximateGP):
def __init__(self, train_x, num_classes):
variational_distribution = CholeskyVariationalDistribution(
train_x.size(0),
batch_shape=torch.Size([num_classes]))
variational_strategy = VariationalStrategy(
self, train_x, variational_distribution,
learn_inducing_locations=True
)
variational_strategy = IndependentMultitaskVariationalStrategy(
variational_strategy, num_tasks=num_classes
)
super(GPClassifier, self).__init__(variational_strategy)
self.mean_module = gpytorch.means.ConstantMean(
batch_shape=torch.Size([num_classes]))
self.covar_module = gpytorch.kernels.ScaleKernel(
gpytorch.kernels.RBFKernel(batch_shape=torch.Size([num_classes])),
batch_shape=torch.Size([num_classes]
))
def forward(self, x):
mean_x = self.mean_module(x)
covar_x = self.covar_module(x)
latent_pred = gpytorch.distributions.MultivariateNormal(mean_x, covar_x)
return latent_pred
model = GPClassifier(X, num_groups)
likelihood = gpytorch.likelihoods.SoftmaxLikelihood(
num_classes=num_groups, mixing_weights=False)
mll = VariationalELBO(likelihood, model, y.numel()) However, from some other issues, the link to the SVDKL paper (cf. Equation 1 at the bottom of page 3) has been mentioned several times, which makes me a bit confused of the correct reference of the method. Some elaborations on these two would really be helpful. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The Hensman paper mostly focuses on binary classification, though the multi-class method is a simple extension of Hensman's method. To extend Hensman's method to multi class, we need to have multiple GPs and we need to replace the quadrature in the likelihood with Monte Carlo sampling. However, the Hensman paper would be an appropriate reference. |
Beta Was this translation helpful? Give feedback.
The Hensman paper mostly focuses on binary classification, though the multi-class method is a simple extension of Hensman's method. To extend Hensman's method to multi class, we need to have multiple GPs and we need to replace the quadrature in the likelihood with Monte Carlo sampling. However, the Hensman paper would be an appropriate reference.