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

different attention map for each element of feature dimension #3

Merged
merged 1 commit into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions point_transformer_pytorch/point_transformer_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(
self.attn_mlp = nn.Sequential(
nn.Linear(dim, dim * attn_mlp_hidden_mult),
nn.ReLU(),
nn.Linear(dim * attn_mlp_hidden_mult, 1),
nn.Linear(dim * attn_mlp_hidden_mult, dim),
)

def forward(self, x, pos):
Expand All @@ -47,8 +47,8 @@ def forward(self, x, pos):
v = v + rel_pos_emb

# attention
attn = sim.softmax(dim = -1)
attn = sim.softmax(dim = -2)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot confirm which axis that the softmax conduct on.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm pretty confident this is the right axis j - sim is (batch x query rows x query-key similarities per row x feature dimension)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm just not sure if the attention MLP does not reduce to one attention map that aggregates across all feature value vectors. if someone else can confirm this is indeed the case, i'll merge and release the corrected version

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, the point transformer in paper is used to informtion exchange or interaction, other than aggregation. The maxpooing in Pointnet++ is assigned to feature aggregation which aggregate many points feature to one point feature. In point transformer layer, the point number of outputs is same as the inputs.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i'll go by your word for now :)


# aggregate
agg = einsum('b i j, b i j d -> b i d', attn, v)
agg = einsum('b i j d, b i j d -> b i d', attn, v)
return agg
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name = 'point-transformer-pytorch',
packages = find_packages(),
version = '0.0.1',
version = '0.0.2',
license='MIT',
description = 'Point Transformer - Pytorch',
author = 'Phil Wang',
Expand Down