Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions roma/mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def procrustes_naive(M, force_rotation: bool = False, return_singular_values: bo
if force_rotation:
DS[flip, -1] *= -1
del D
DS = roma.internal.unflatten_batch_dims(DS, batch_shape)
return R, DS


Expand Down
13 changes: 13 additions & 0 deletions test/test_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ def test_special_procrustes(self):
Rter = roma.special_procrustes_naive(M)
self.assertTrue(is_close(R, Rter))

def test_procrustes_naive_singular_values_shape(self):
torch.manual_seed(666)
# Compare with procrustes for zero, one and two batch dimensions.
for batch_shape in ((), (10,), (2, 5)):
M = torch.randn(batch_shape + (3, 3), dtype=torch.float64, device=device)
for force_rotation in (False, True):
R, DS = roma.procrustes(M, force_rotation=force_rotation, return_singular_values=True)
Rbis, DSbis = roma.procrustes_naive(M, force_rotation=force_rotation, return_singular_values=True)
self.assertEqual(Rbis.shape, batch_shape + (3, 3))
self.assertEqual(DSbis.shape, batch_shape + (3,))
self.assertTrue(is_close(R, Rbis))
self.assertTrue(is_close(DS, DSbis))

def test_special_gramschmidt(self):
torch.manual_seed(666)
for dtype in (torch.float32, torch.float64):
Expand Down
Loading