Pytorch3d: R=I outputs nans in so3_log_map()

Created on 7 May 2020  路  1Comment  路  Source: facebookresearch/pytorch3d

When identity matrix is fed into so3_log_map() output is filled with nans:

~~~~
from pytorch3d.transforms.so3 import so3_log_map
import torch

R = torch.eye(3).unsqueeze(0)
ax_angle = so3_log_map(R)

print(ax_angle)
~~~~

It seems that when phi = 0 the phi.sign() outputs zero which further sets phi_valid to zero:https://github.com/facebookresearch/pytorch3d/blob/17ca6ecd81b49751fd4adcbd6effee9f3fbfc455/pytorch3d/transforms/so3.py#L155

bug question

Most helpful comment

Hi,

thanks a lot for pointing this out. We will very soon push a fix to this.
In case you need an urgent fix and can't wait for us to push it, you can replace
phi_valid = torch.clamp(phi.abs(), eps) * phi.sign()
with
phi_valid = torch.clamp(phi.abs(), eps) * phi.sign() + (phi == 0).type_as(phi) * eps

>All comments

Hi,

thanks a lot for pointing this out. We will very soon push a fix to this.
In case you need an urgent fix and can't wait for us to push it, you can replace
phi_valid = torch.clamp(phi.abs(), eps) * phi.sign()
with
phi_valid = torch.clamp(phi.abs(), eps) * phi.sign() + (phi == 0).type_as(phi) * eps

Was this page helpful?
0 / 5 - 0 ratings

Related issues

farhanrw picture farhanrw  路  3Comments

unlugi picture unlugi  路  3Comments

shersoni610 picture shersoni610  路  3Comments

unlugi picture unlugi  路  3Comments

TSKongLingwei picture TSKongLingwei  路  3Comments