-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfModel.py
35 lines (26 loc) · 894 Bytes
/
ConfModel.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
import torch.nn as nn
import torch as th
import torch.nn.functional as F
from pytorch_revgrad import RevGrad
class ConfModelBC(nn.Module):
def __init__(self, nOut, num_layers=2, **kwargs):
super(ConfModelBC, self).__init__()
self.out_features = nOut
self.in_features = nOut*2
self.num_layers = num_layers
layers = [RevGrad()]
layers.append(th.nn.Sequential(
nn.BatchNorm1d(self.in_features),
th.nn.ReLU(inplace=True),
th.nn.Linear(self.in_features,512),
))
layers.append(th.nn.Sequential(
nn.BatchNorm1d(512),
th.nn.ReLU(inplace=True),
th.nn.Linear(512,2),
))
self.matcher = th.nn.Sequential(*layers)
def reset_parameters(self):
self.matcher.reset_parameters()
def forward(self, x):
return self.matcher(x)