mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-19 13:50:35 +08:00
remove requires_grad from random rotations
Summary: Because rotations and (rotation) quaternions live on curved manifolds, it doesn't make sense to optimize them directly. Having a prominent option to require gradient on random ones may cause people to try, and isn't particularly useful. Reviewed By: theschnitz Differential Revision: D29160734 fbshipit-source-id: fc9e320672349fe334747c5b214655882a460a62
This commit is contained in:
committed by
Facebook GitHub Bot
parent
31c448a95d
commit
ce60d4b00e
@@ -76,7 +76,8 @@ class TestRotationConversion(TestCaseMixin, unittest.TestCase):
|
||||
|
||||
def test_quat_grad_exists(self):
|
||||
"""Quaternion calculations are differentiable."""
|
||||
rotation = random_rotation(requires_grad=True)
|
||||
rotation = random_rotation()
|
||||
rotation.requires_grad = True
|
||||
modified = quaternion_to_matrix(matrix_to_quaternion(rotation))
|
||||
[g] = torch.autograd.grad(modified.sum(), rotation)
|
||||
self.assertTrue(torch.isfinite(g).all())
|
||||
@@ -131,7 +132,8 @@ class TestRotationConversion(TestCaseMixin, unittest.TestCase):
|
||||
|
||||
def test_euler_grad_exists(self):
|
||||
"""Euler angle calculations are differentiable."""
|
||||
rotation = random_rotation(dtype=torch.float64, requires_grad=True)
|
||||
rotation = random_rotation(dtype=torch.float64)
|
||||
rotation.requires_grad = True
|
||||
for convention in self._all_euler_angle_conventions():
|
||||
euler_angles = matrix_to_euler_angles(rotation, convention)
|
||||
mdata = euler_angles_to_matrix(euler_angles, convention)
|
||||
@@ -218,7 +220,8 @@ class TestRotationConversion(TestCaseMixin, unittest.TestCase):
|
||||
|
||||
def test_quaternion_application(self):
|
||||
"""Applying a quaternion is the same as applying the matrix."""
|
||||
quaternions = random_quaternions(3, torch.float64, requires_grad=True)
|
||||
quaternions = random_quaternions(3, torch.float64)
|
||||
quaternions.requires_grad = True
|
||||
matrices = quaternion_to_matrix(quaternions)
|
||||
points = torch.randn(3, 3, dtype=torch.float64, requires_grad=True)
|
||||
transform1 = quaternion_apply(quaternions, points)
|
||||
|
||||
Reference in New Issue
Block a user