-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmodel.py
66 lines (55 loc) · 2.1 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import torch.nn as nn
import torch.nn.functional as F
class DeepHomographyModel(nn.Module):
def __init__(self):
super(DeepHomographyModel, self).__init__()
self.conv_layer1 = nn.Conv2d(2,64,3,padding=1)
self.conv_layer2 = nn.Conv2d(64,64,3,padding=1)
self.conv_layer3 = nn.Conv2d(64,64,3,padding=1)
self.conv_layer4 = nn.Conv2d(64,64,3,padding=1)
self.conv_layer5 = nn.Conv2d(64,128,3,padding=1)
self.conv_layer6 = nn.Conv2d(128,128,3,padding=1)
self.conv_layer7 = nn.Conv2d(128,128,3,padding=1)
self.conv_layer8 = nn.Conv2d(128,128,3,padding=1)
self.fc_layer1 = nn.Linear(128*16*16,1024)
self.fc_layer2 = nn.Linear(1024,8)
self.batch_norm1 = nn.BatchNorm2d(64)
self.batch_norm2 = nn.BatchNorm2d(64)
self.batch_norm3 = nn.BatchNorm2d(64)
self.batch_norm4 = nn.BatchNorm2d(64)
self.batch_norm5 = nn.BatchNorm2d(128)
self.batch_norm6 = nn.BatchNorm2d(128)
self.batch_norm7 = nn.BatchNorm2d(128)
self.batch_norm8 = nn.BatchNorm2d(128)
def forward(self,x):
out = self.conv_layer1(x)
out = self.batch_norm1(out)
out = F.relu(out)
out = self.conv_layer2(out)
out = self.batch_norm2(out)
out = F.relu(out)
out = F.max_pool2d(out, 2)
out = self.conv_layer3(out)
out = self.batch_norm3(out)
out = F.relu(out)
out = self.conv_layer4(out)
out = self.batch_norm4(out)
out = F.relu(out)
out = F.max_pool2d(out, 2)
out = self.conv_layer5(out)
out = self.batch_norm5(out)
out = F.relu(out)
out = self.conv_layer6(out)
out = self.batch_norm6(out)
out = F.relu(out)
out = F.max_pool2d(out, 2)
out = self.conv_layer7(out)
out = self.batch_norm7(out)
out = F.relu(out)
out = self.conv_layer8(out)
out = self.batch_norm8(out)
out = F.relu(out)
out = out.view(-1,128*16*16)
out = self.fc_layer1(out)
out = self.fc_layer2(out)
return out