MCPcopy Create free account
hub / github.com/TEA-Lab/TwoByTwo / VNMaxPool

Class VNMaxPool

src/shape_assembly/models/encoder/vn_layers.py:167–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165
166
167class VNMaxPool(nn.Module):
168 def __init__(self, in_channels):
169 super(VNMaxPool, self).__init__()
170 self.map_to_dir = nn.Linear(in_channels, in_channels, bias=False)
171
172 def forward(self, x):
173 '''
174 x: point features of shape [B, N_feat, 3, N_samples, ...]
175 '''
176 d = self.map_to_dir(x.transpose(1, -1)).transpose(1, -1)
177 dotprod = (x * d).sum(2, keepdims=True)
178 idx = dotprod.max(dim=-1, keepdim=False)[1]
179 index_tuple = torch.meshgrid([torch.arange(j) for j in x.size()[:-1]]) + (idx,)
180 x_max = x[index_tuple]
181 return x_max
182
183
184def mean_pool(x, dim=-1, keepdim=False):

Callers 3

__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected