-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdiscriminator.py
39 lines (34 loc) · 899 Bytes
/
discriminator.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
"""
This class defines the Discriminator Network
"""
from torch.nn import Module, Sequential, Linear, ReLU, Sigmoid, Dropout
class Discriminator(Module):
def __init__(self):
super(Discriminator, self).__init__()
d_input = 28*28
d_output = 1
self.input = Sequential(
Linear(d_input, 1024),
ReLU(),
Dropout(0.2)
)
self.hidden1 = Sequential(
Linear(1024, 512),
ReLU(),
Dropout(0.2)
)
self.hidden2 = Sequential(
Linear(512, 256),
ReLU(),
Dropout(0.2)
)
self.output = Sequential(
Linear(256, d_output),
Sigmoid()
)
def forward(self, x):
x = self.input(x)
x = self.hidden1(x)
x = self.hidden2(x)
x = self.output(x)
return x