mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-22 07:10:34 +08:00
Replace torch.det() with manual implementation for 3x3 matrix
Summary: # Background There is an unstable error during training (it can happen after several minutes or after several hours). The error is connected to `torch.det()` function in `_check_valid_rotation_matrix()`. if I remove the function `torch.det()` in `_check_valid_rotation_matrix()` or remove the whole functions `_check_valid_rotation_matrix()` the error is disappeared (D29555876). # Solution Replace `torch.det()` with manual implementation for 3x3 matrix. Reviewed By: patricklabatut Differential Revision: D29655924 fbshipit-source-id: 41bde1119274a705ab849751ece28873d2c45155
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2f668ecefe
commit
bcee361d04
@@ -11,6 +11,7 @@ from typing import List, Optional, Union
|
||||
import torch
|
||||
|
||||
from ..common.types import Device, get_device, make_device
|
||||
from ..common.workaround import _safe_det_3x3
|
||||
from .rotation_conversions import _axis_angle_rotation
|
||||
|
||||
|
||||
@@ -774,7 +775,7 @@ def _check_valid_rotation_matrix(R, tol: float = 1e-7):
|
||||
eye = torch.eye(3, dtype=R.dtype, device=R.device)
|
||||
eye = eye.view(1, 3, 3).expand(N, -1, -1)
|
||||
orthogonal = torch.allclose(R.bmm(R.transpose(1, 2)), eye, atol=tol)
|
||||
det_R = torch.det(R)
|
||||
det_R = _safe_det_3x3(R)
|
||||
no_distortion = torch.allclose(det_R, torch.ones_like(det_R))
|
||||
if not (orthogonal and no_distortion):
|
||||
msg = "R is not a valid rotation matrix"
|
||||
|
||||
Reference in New Issue
Block a user