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

The code correspondence of the paper formula 5? #76

Open
deepConnectionism opened this issue Sep 18, 2024 · 1 comment
Open

The code correspondence of the paper formula 5? #76

deepConnectionism opened this issue Sep 18, 2024 · 1 comment

Comments

@deepConnectionism
Copy link

deepConnectionism commented Sep 18, 2024

image

I checked the source code and I want to know:
image

How is this reflected in the code? I can't find it.

I found the code:

class SoftAgg(nn.Module):
    def __init__(self, dim=512, expand=True):
        super(SoftAgg, self).__init__()
        self.dim = dim
        self.expand = expand
        self.f = nn.Linear(self.dim, self.dim)
        self.g = nn.Linear(self.dim, self.dim)
        self.h = nn.Linear(self.dim, self.dim)

    def forward(self, x, ix):
        _, jx = torch.unique(ix, return_inverse=True)
        w = torch_scatter.scatter_softmax(self.g(x), jx, dim=1)
        y = torch_scatter.scatter_sum(self.f(x) * w, jx, dim=1)

        if self.expand:
            return self.h(y)[:,jx]
            
        return self.h(y)

And for:

net = net + self.agg_ij(net, ii*12345 + jj)

Why 12345?

@deepConnectionism
Copy link
Author

Through the search, I knew what 12345 meant

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

1 participant