pypose.module.GeodesicLoss¶
- class pypose.module.GeodesicLoss(reduction='mean')[source]¶
Creates a criterion that measures the Geodesic Error between the rotation part of the input LieTensor \(x\) and target LieTensor \(y\).
\[\operatorname{norm}(\operatorname{Log}(\mathbf{x}\times\mathbf{y}^{-1})). \]Warning
The above equation holds only if \(x\) and \(y\) are quaternions. When \(x\) and \(y\) are rotation matrices, the geodesic error is
\[\arccos \left(\frac{\operatorname{trace}( \mathbf{x}\times\mathbf{y}^{-1})-1}{2}\right). \]This class accepts all forms of input LieTensors, including
SO3,SE3,RxSO3,Sim3,so3,se3,rxso3,sim3, where their rotation part will be extracted.- Parameters:
reduction (
str, optional) – Specifies the reduction to apply to the output:'none'|'mean'|'sum'.'none': no reduction is applied,'mean': the sum of the output is divided by the number of elements in the output,'sum': the output is summed. Default:'mean'
Examples
>>> input, target = pp.randn_SO3(2), pp.randn_SO3(2) >>> criterion = pp.module.GeodesicLoss(reduction='mean') >>> loss = criterion(input, target) tensor(1.0112)