-
Notifications
You must be signed in to change notification settings - Fork 17
/
model.py
36 lines (28 loc) · 993 Bytes
/
model.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
34
35
36
import torch
import torch.nn as nn
class SimplePnPNet(nn.Module):
def __init__(self, nIn):
super(SimplePnPNet, self).__init__()
self.conv1 = torch.nn.Conv1d(nIn, 128, 1)
self.conv2 = torch.nn.Conv1d(128, 128, 1)
self.conv3 = torch.nn.Conv1d(128, 128, 1)
self.fc1 = nn.Linear(1024, 512)
self.fc2 = nn.Linear(512, 256)
self.fc_qt = nn.Linear(256, 7)
self.act = nn.LeakyReLU(0.1, inplace=True)
def forward(self, x):
batch_size = x.size(0)
data_size = x.size(2) # number of correspondences
x = self.act(self.conv1(x))
x = self.act(self.conv2(x))
x = self.conv3(x)
x = x.view(batch_size, 128, -1, 8)
x = torch.max(x, dim=2, keepdim=True)[0]
# x = torch.mean(x, dim=2, keepdim=True)
x = x.view(batch_size, 1024)
#
x = self.act(self.fc1(x))
x = self.act(self.fc2(x))
#
qt = self.fc_qt(x)
return qt