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

squash #7

Open
yimzhai3 opened this issue Mar 27, 2019 · 0 comments
Open

squash #7

yimzhai3 opened this issue Mar 27, 2019 · 0 comments

Comments

@yimzhai3
Copy link

yimzhai3 commented Mar 27, 2019

I have a question: according to the paper, the squash function only be used after the sum of prediction u-hat? and in this code, there is a squash after the primary capsule. I got really confused.
class PrimaryCapsLayer(nn.Module): def __init__(self, input_channels, output_caps, output_dim, kernel_size, stride): super(PrimaryCapsLayer, self).__init__() self.conv = nn.Conv2d(input_channels, output_caps * output_dim, kernel_size=kernel_size, stride=stride) # input_channels = 256,output_caps = 32, output_dim = 8, kernel_size = 9, stride = 2 self.input_channels = input_channels self.output_caps = output_caps self.output_dim = output_dim def forward(self, input): out = self.conv(input) N, C, H, W = out.size() out = out.view(N, self.output_caps, self.output_dim, H, W) # will output N x OUT_CAPS x OUT_DIM out = out.permute(0, 1, 3, 4, 2).contiguous() out = out.view(out.size(0), -1, out.size(4)) out = squash(out) #####QUESTION?? return out

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