-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattack_models.py
52 lines (41 loc) · 1.59 KB
/
attack_models.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
# define the different types of attack models here
from torch import nn
class BasicNN(nn.Module):
def __init__(self, in_features, hidden_features=64, out_features=2) -> None:
super(BasicNN, self).__init__()
self.network = nn.Sequential(
nn.Linear(in_features, hidden_features),
nn.Dropout(),
nn.Tanh(),
nn.Linear(hidden_features, out_features)
)
def forward(self, x):
return self.network(x)
class BasicNN_v2(nn.Module):
def __init__(self, in_features, hidden_features=64, out_features=2) -> None:
super(BasicNN_v2, self).__init__()
self.network = nn.Sequential(
nn.Linear(in_features, hidden_features*2),
nn.Dropout(),
nn.Tanh(),
nn.Linear(hidden_features*2, hidden_features*4),
nn.Dropout(),
nn.Tanh(),
nn.Linear(hidden_features*4, out_features)
)
def forward(self, x):
return self.network(x)
# class BasicCNN(nn.Module):
# def __init__(self, in_features, hidden_features=64, out_features=2) -> None:
# super(BasicNN, self).__init__()
# self.network = nn.Sequential(
# nn.Conv2d(in_channels=1, out_channels=3, kernel_size=5),
# nn.Linear(in_features, hidden_features),
# nn.Dropout(),
# nn.Tanh(),
# nn.Linear(hidden_features, hidden_features*2),
# nn.Tanh(),
# nn.Linear(hidden_features*2, out_features)
# )
# def forward(self, x):
# return self.network(x)