-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
42 lines (35 loc) · 1.23 KB
/
models.py
File metadata and controls
42 lines (35 loc) · 1.23 KB
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
"""
This code is from https://github.com/Machine-Learning-Security-Lab/mia_prune
"""
import torch.nn.functional as F
from torch import nn
class ColumnFC(nn.Module):
def __init__(self, input_dim=100, output_dim=100, dropout=0.1):
super(ColumnFC, self).__init__()
self.fc1 = nn.Linear(input_dim, 256)
self.drop1 = nn.Dropout(dropout)
self.fc2 = nn.Linear(256, 128)
self.fc3 = nn.Linear(128, output_dim)
self.drop2 = nn.Dropout(dropout)
def forward(self, x):
x = self.drop1(F.relu(self.fc1(x)))
x = self.drop2(F.relu(self.fc2(x)))
x = self.fc3(x)
return x
class MIAFC(nn.Module):
def __init__(self, input_dim=10, output_dim=1, dropout=0.2):
super(MIAFC, self).__init__()
self.fc1 = nn.Linear(input_dim, 512)
self.dropout1 = nn.Dropout(dropout)
self.fc2 = nn.Linear(512, 256)
self.dropout2 = nn.Dropout(dropout)
self.fc3 = nn.Linear(256, 128)
self.fc4 = nn.Linear(128, output_dim)
def forward(self, x):
x = F.relu(self.fc1(x))
x = self.dropout1(x)
x = F.relu(self.fc2(x))
x = self.dropout2(x)
x = F.relu(self.fc3(x))
x = self.fc4(x)
return x