Improve reliability of svgp test
@@ -64,15 +64,18 @@ class TestSVGPRegression(unittest.TestCase):
def test_regression_error(self):
train_x, train_y = train_data()
likelihood = GaussianLikelihood()
- model = SVGPRegressionModel(train_x[:25])
+ model = SVGPRegressionModel(torch.linspace(0, 1, 25))
mll = gpytorch.mlls.VariationalELBO(likelihood, model, num_data=len(train_y))
# Find optimal model hyperparameters
model.train()
likelihood.train()
- optimizer = optim.Adam([{'params': model.parameters()}, {'params': likelihood.parameters()}], lr=0.1)
+ optimizer = optim.Adam([
+ {'params': model.parameters()},
+ {'params': likelihood.parameters()},
+ ], lr=0.01)
optimizer.n_iter = 0
- for _ in range(250):
+ for _ in range(150):
optimizer.zero_grad()
output = model(train_x)
loss = -mll(output, train_y)
@@ -97,14 +100,14 @@ class TestSVGPRegression(unittest.TestCase):
if torch.cuda.is_available():
train_x, train_y = train_data(cuda=True)
likelihood = GaussianLikelihood().cuda()
- model = SVGPRegressionModel(train_x[:25]).cuda()
+ model = SVGPRegressionModel(torch.linspace(0, 1, 25)).cuda()
mll = gpytorch.mlls.VariationalMarginalLogLikelihood(likelihood, model, num_data=len(train_y))
# Find optimal model hyperparameters
model.train()
- optimizer = optim.Adam([{'params': model.parameters()}, {'params': likelihood.parameters()}], lr=0.1)
+ optimizer = optim.Adam([{'params': model.parameters()}, {'params': likelihood.parameters()}], lr=0.01)
optimizer.n_iter = 0
- for _ in range(250):
+ for _ in range(150):
optimizer.zero_grad()
output = model(train_x)
loss = -mll(output, train_y)
