papagina / RotationContinuity

Coder for "On the Continuity of Rotation Representations"
MIT License
320 stars 54 forks source link

sanity_check issue with geodesic loss #11

Open fenaux opened 1 year ago

fenaux commented 1 year ago

In order to avoid loss is Nan

In compute_geodesic_distance_from_two_matrices(m1, m2) I changed cos = torch.min(cos, torch.autograd.Variable(torch.ones(batch).cuda()) ) cos = torch.max(cos, torch.autograd.Variable(torch.ones(batch).cuda())-1 ) to cos = torch.min(cos, torch.autograd.Variable(torch.ones(batch).cuda()) 0.9999) cos = torch.max(cos, torch.autograd.Variable(torch.ones(batch).cuda()) * -0.9999 )

then training ran but after few iterations I got a constant error and the same for all models Then I realized their is a problem as teta value can be negative and in model definition we have def compute_geodesic_loss(self, gt_r_matrix, out_r_matrix): theta = tools.compute_geodesic_distance_from_two_matrices(gt_r_matrix, out_r_matrix) error = theta.mean() return error so if I am not wrong error can be negative

I tried In compute_geodesic_distance_from_two_matrices(m1, m2) at the end : return torch.abs( teta)

I now have a steady decrease of geodesic loss for all the models :) after 100000 iterations ortho6d 0.018 ortho5d 0.021 quaternion 0.162 euler 0.198 rodriguez 0.104 euler_sin_cos 0.066 Quaternion_half 0.041

Frank-ZY-Dou commented 2 weeks ago

You could have a check here: https://pytorch3d.readthedocs.io/en/latest/modules/transforms.html#pytorch3d.transforms.so3_relative_angle