forked from vccheng2001/DeepVCP-Pointcloud-Registration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
weighting_layer.py
33 lines (30 loc) · 946 Bytes
/
weighting_layer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.modules.activation import ReLU, Softplus
from torch.nn.modules.batchnorm import BatchNorm1d
from torch.nn.modules.linear import Linear
class weighting_layer(nn.Module):
def __init__(self):
super(weighting_layer, self).__init__()
self.fc1 = nn.Sequential(
nn.Linear(32, 16, True),
# nn.BatchNorm1d(10000),
nn.ReLU()
)
self.fc2 = nn.Sequential(
nn.Linear(16, 8, True),
# nn.BatchNorm1d(8),
nn.ReLU()
)
self.fc3 = nn.Sequential(
nn.Linear(8, 1, True),
nn.Softplus()
)
def forward(self, X, K = 64):
X = self.fc1(X)
X = self.fc2(X)
X = self.fc3(X)
topk_indices = torch.topk(X, K, dim = 1).indices
topk_indices = topk_indices.flatten()
return topk_indices