Check parameter gradients for SGPR
@@ -77,6 +77,13 @@ class TestSGPRRegression(unittest.TestCase):
loss.backward()
optimizer.step()
+ for param in gp_model.parameters():
+ self.assertTrue(param.grad is not None)
+ self.assertGreater(param.grad.norm().item(), 0)
+ for param in likelihood.parameters():
+ self.assertTrue(param.grad is not None)
+ self.assertGreater(param.grad.norm().item(), 0)
+
# Test the model
gp_model.eval()
likelihood.eval()
@@ -110,6 +117,13 @@ class TestSGPRRegression(unittest.TestCase):
optimizer.n_iter += 1
optimizer.step()
+ for param in gp_model.parameters():
+ self.assertTrue(param.grad is not None)
+ self.assertGreater(param.grad.norm().item(), 0)
+ for param in likelihood.parameters():
+ self.assertTrue(param.grad is not None)
+ self.assertGreater(param.grad.norm().item(), 0)
+
# Test the model
gp_model.eval()
likelihood.eval()
