Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'pos2posemb3d' in positional_encoding.py #222

Open
zyxu1996 opened this issue Aug 13, 2024 · 1 comment
Open

'pos2posemb3d' in positional_encoding.py #222

zyxu1996 opened this issue Aug 13, 2024 · 1 comment

Comments

@zyxu1996
Copy link

zyxu1996 commented Aug 13, 2024

https://github.com/exiawsh/StreamPETR/blob/main/projects/mmdet3d_plugin/models/utils/positional_encoding.py#L25

Is there any special design to transpose 'x' & 'y' dimentions ?

def pos2posemb3d(pos, num_pos_feats=128, temperature=10000):
    scale = 2 * math.pi
    dim_t = torch.arange(num_pos_feats//2, dtype=torch.float32, device=pos.device)
    dim_t = temperature ** (2 * dim_t / num_pos_feats)
    pos_x = pos[..., 0, None]* scale / dim_t
    pos_y = pos[..., 1, None]* scale / dim_t
    pos_z = pos[..., 2, None]* scale / dim_t
    pos_x = torch.stack((pos_x.sin(), pos_x.cos()), dim=-1).flatten(-2)
    pos_y = torch.stack((pos_y.sin(), pos_y.cos()), dim=-1).flatten(-2)
    pos_z = torch.stack((pos_z.sin(), pos_z.cos()), dim=-1).flatten(-2)
    posemb = torch.cat((pos_y, pos_x, pos_z), dim=-1)
    return posemb
@czy9987
Copy link

czy9987 commented Nov 26, 2024

The same question consultation, here seems to be written backwards, anyone clear?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants