Skip to content

3D DGP Regression crashes from not enough RAM #2637

Closed Answered by anja-sheppard
anja-sheppard asked this question in Q&A
Discussion options

You must be logged in to vote

Batching the predictions like this helped. Hopefully this can help someone else!

batch_size = 20
model.eval()
with torch.no_grad(), gpytorch.settings.fast_pred_var():
    test_x1 = torch.linspace(0, 1, 20)
    test_x2 = torch.linspace(0, 1, 20)
    test_x1_grid, test_x2_grid = torch.meshgrid(test_x1, test_x2)
    test_X = torch.stack([test_x1_grid.flatten(), test_x2_grid.flatten()]).T
    means, variances = [], []
    for i in range(0, test_X.size(0), batch_size):
        batch = test_X[i:i+batch_size]
        mean, var = model.predict(batch)
        means.append(mean)
        variances.append(var)
    pred_mean = torch.cat(means)
    pred_var = torch.cat(variances)

Replies: 1 comment

Comment options

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