Shortcuts

pypose.LieTensor

class pypose.LieTensor(*data, ltype)[source]

A sub-class of torch.Tensor to represent Lie Algebra and Lie Group.

Parameters
  • data (Tensor, or list, or ‘int…’) –

    A Tensor object, or constructing a Tensor object from list, which defines tensor data, or from ‘int…’, which defines tensor shape.

    The shape of Tensor object should be compatible with Lie Type ltype, 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 ltype for Lie Group

Representation

ltype

shape

Alias Class

Rotation

SO3_type

(*, 4)

SO3()

Translation + Rotation

SE3_type

(*, 7)

SE3()

Translation + Rotation + Scale

Sim3_type

(*, 8)

Sim3()

Rotation + Scale

RxSO3_type

(*, 5)

RxSO3()

List of ltype for Lie Algebra

Representation

ltype

shape

Alias Class

Rotation

so3_type

(*, 3)

so3()

Translation + Rotation

se3_type

(*, 6)

se3()

Translation + Rotation + Scale

sim3_type

(*, 7)

sim3()

Rotation + Scale

rxso3_type

(*, 4)

rxso3()

Note

Two attributes shape and lshape are available for LieTensor. The only differece is the lshape hides the last dimension of shape, since lshape takes the data in the last dimension as a single ltype item.

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, and requires_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 Exp and Log.

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 self LieTensor

Return type

LieTensor

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 shape is the last dimension is hidden, since lshape takes the last dimension as a single ltype item.

  • 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 size filled with uninitialized data. By default, the returned Tensor has the same torch.dtype and torch.device as this tensor.

Parameters

size (int...) – a list, tuple, or torch.Size of integers defining the shape of the output tensor.

Keyword Arguments
  • dtype (torch.dtype, optional) – the desired type of returned tensor. Default: if None, same torch.dtype as this tensor.

  • device (torch.device, optional) – the desired device of returned tensor. Default: if None, same torch.device as 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]])
rotation()[source]

See pypose.rotation()

scale()[source]

See pypose.scale()

tensor()[source]

See pypose.tensor()

translation()[source]

See pypose.translation()

Docs

Access documentation for PyPose

View Docs

Tutorials

Get started with tutorials and examples

View Tutorials

Get Started

Find resources and how to start using pypose

View Resources