pypose.LieTensor¶
- class pypose.LieTensor(*data, ltype)[source]¶
A sub-class of
torch.Tensorto represent Lie Algebra and Lie Group.- Parameters
data (
Tensor, orlist, or ‘int…’) –A
Tensorobject, or constructing aTensorobject fromlist, which defines tensor data, or from ‘int…’, which defines tensor shape.The shape of
Tensorobject should be compatible with Lie Typeltype, otherwise error will be raised.ltype (
ltype) – Lie Type, either Lie Group or Lie Algebra is listed below:
- Returns
LieTensor corresponding to Lie Type
ltype.
List of ltypefor Lie Group¶Representation
ltypeshapeAlias Class
Rotation
SO3_type(*, 4)Translation + Rotation
SE3_type(*, 7)Translation + Rotation + Scale
Sim3_type(*, 8)Rotation + Scale
RxSO3_type(*, 5)List of ltypefor Lie Algebra¶Representation
ltypeshapeAlias Class
Rotation
so3_type(*, 3)Translation + Rotation
se3_type(*, 6)Translation + Rotation + Scale
sim3_type(*, 7)Rotation + Scale
rxso3_type(*, 4)Note
Two attributes
shapeandlshapeare available for LieTensor. The only differece is thelshapehides the last dimension ofshape, sincelshapetakes the data in the last dimension as a singleltypeitem.See LieTensor method
lview()for more details.Examples
>>> import torch >>> import pypose as pp >>> data = torch.randn(3, 3, requires_grad=True, device='cuda:0') >>> pp.LieTensor(data, ltype=pp.so3_type) so3Type LieTensor: tensor([[ 0.9520, 0.4517, 0.5834], [-0.8106, 0.8197, 0.7077], [-0.5743, 0.8182, -1.2104]], device='cuda:0', grad_fn=<AliasBackward0>)
Alias class for specific LieTensor is recommended:
>>> pp.so3(data) so3Type LieTensor: tensor([[ 0.9520, 0.4517, 0.5834], [-0.8106, 0.8197, 0.7077], [-0.5743, 0.8182, -1.2104]], device='cuda:0', grad_fn=<AliasBackward0>)
See more alias classes at Table 1 for Lie Group and Table 2 for Lie Algebra.
Other constructors:
From list.
>>> pp.so3([0, 0, 0]) so3Type LieTensor: tensor([0., 0., 0.])
From ints.
>>> pp.so3(2, 3) so3Type LieTensor: tensor([[0., 0., 0.], [0., 0., 0.]])
Note
Alias class for LieTensor is recommended. For example, the following usage is equivalent:
pp.LieTensor(tensor, ltype=pp.so3_type)pp.so3(tensor)(This is preferred).
Note
All attributes from Tensor are available for LieTensor, e.g.,
dtype,device, andrequires_grad. See more details at tensor attributes.Example:
>>> data = torch.randn(1, 3, dtype=torch.float64, device="cuda", requires_grad=True) >>> pp.so3(data) # All Tensor attributes are available for LieTensor so3Type LieTensor: tensor([[-1.5948, 0.3113, -0.9807]], device='cuda:0', dtype=torch.float64, grad_fn=<AliasBackward0>)
Note
In most of the cases, Lie Group is expected to be used, therefore we only provide converting functions between Lie Groups and other data structures, e.g., transformation matrix, Euler angle, etc. The users can convert data between Lie Group and Lie algebra with
ExpandLog.- Act(p)[source]¶
See
pypose.Act()
- Adj(a)[source]¶
See
pypose.Adj()
- AdjT(a)[source]¶
See
pypose.AdjT()
- Exp()[source]¶
See
pypose.Exp()
- Inv()[source]¶
See
pypose.Inv()
- Jinvp(p)[source]¶
See
pypose.Jinvp()
- Jr()[source]¶
See
pypose.Jr()
- Log()[source]¶
See
pypose.Log()
- Retr(a)[source]¶
See
pypose.Retr()
- add(other, alpha=1)[source]¶
See
pypose.add()
- add_(other, alpha=1)[source]¶
See
pypose.add_()
- cummul(dim)[source]¶
See
pypose.cummul()
- cummul_(dim)[source]¶
Inplace version of
pypose.cummul()
- cumops(dim, ops)[source]¶
See
pypose.cumops()
- cumops_(dim, ops)[source]¶
Inplace version of
pypose.cumops()
- cumprod(dim, left=True)[source]¶
See
pypose.cumprod()
- cumprod_(dim)[source]¶
Inplace version of
pypose.cumprod()
- euler(eps=0.0002)[source]¶
See
pypose.euler()
- identity_()[source]¶
Inplace set the LieTensor to identity.
- Returns
the
selfLieTensor- Return type
Note
The translation part, if there is, is set to zeros, while the rotation part is set to identity quaternion.
Example
>>> x = pp.randn_SO3(2) >>> x SO3Type LieTensor: tensor([[-0.0724, 0.1970, 0.0022, 0.9777], [ 0.3492, 0.4998, -0.5310, 0.5885]]) >>> x.identity_() SO3Type LieTensor: tensor([[0., 0., 0., 1.], [0., 0., 0., 1.]])
- property lshape¶
LieTensor Shape (shape of torch.Tensor by ignoring the last dimension)
- Returns
torch.Size
Note
The only difference from
shapeis the last dimension is hidden, sincelshapetakes the last dimension as a singleltypeitem.The last dimension can also be accessed via
LieTensor.ltype.dimension.
Examples
>>> x = pp.randn_SE3(2) >>> x.lshape torch.Size([2]) >>> x.shape torch.Size([2, 7]) >>> x.ltype.dimension torch.Size([7])
- lview(*shape)[source]¶
Returns a new LieTensor with the same data as the self tensor but of a different
lshape.- Parameters
shape (torch.Size or int...) – the desired size
- Returns
A new lieGroup tensor sharing with the same data as the self tensor but of a different shape.
Note
The only difference from
view()is the last dimension is hidden.See Tensor.view for its usage.
Examples
>>> x = pp.randn_so3(2,2) >>> x.shape torch.Size([2, 2, 3]) >>> x.lview(-1).lshape torch.Size([4])
- matrix()[source]¶
See
pypose.matrix()
- new_empty(size, *, dtype=None, device=None, requires_grad=False, layout=torch.strided, pin_memory=False) Tensor[source]¶
Returns a Tensor of size
sizefilled with uninitialized data. By default, the returned Tensor has the sametorch.dtypeandtorch.deviceas this tensor.- Parameters
size (int...) – a list, tuple, or
torch.Sizeof integers defining the shape of the output tensor.- Keyword Arguments
dtype (
torch.dtype, optional) – the desired type of returned tensor. Default: if None, sametorch.dtypeas this tensor.device (
torch.device, optional) – the desired device of returned tensor. Default: if None, sametorch.deviceas this tensor.requires_grad (bool, optional) – If autograd should record operations on the returned tensor. Default:
False.layout (
torch.layout, optional) – the desired layout of returned Tensor. Default:torch.strided.pin_memory (bool, optional) – If set, returned tensor would be allocated in the pinned memory. Works only for CPU tensors. Default:
False.
Example:
>>> tensor = torch.ones(()) >>> tensor.new_empty((2, 3)) tensor([[ 5.8182e-18, 4.5765e-41, -1.0545e+30], [ 3.0949e-41, 4.4842e-44, 0.0000e+00]])
- scale()[source]¶
See
pypose.scale()
- tensor()[source]¶
See
pypose.tensor()