-
Notifications
You must be signed in to change notification settings - Fork 1
/
model2.py
62 lines (52 loc) · 1.37 KB
/
model2.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
# -*- coding: utf-8 -*-
import torch.nn as nn
from utils.nn import Maxout
# model parameters
nz = 100 # number of visual ujnis
keep_prob_default = 0.5
keep_prob_h0 = 0.8
scale_factor_default = 2
scale_factor_h0 = 1.25
class Generator(nn.Module):
def __init__(self):
super(Generator, self).__init__()
self.L1 = nn.Sequential(
nn.Linear(nz, 1200),
nn.BatchNorm1d(1200),
nn.ReLU()
)
self.L2 = nn.Sequential(
nn.Linear(1200, 1200),
nn.BatchNorm1d(1200),
nn.ReLU()
)
self.L3 = nn.Sequential(
nn.Linear(1200, 784),
nn.Sigmoid()
)
def forward(self, x):
x = self.L1(x)
x = self.L2(x)
x = self.L3(x)
return x
class Discriminator(nn.Module):
def __init__(self):
super(Discriminator, self).__init__()
self.L1 = nn.Sequential(
nn.Dropout(1 - keep_prob_h0),
Maxout(784, 240, 5),
)
self.L2 = nn.Sequential(
nn.Dropout(1 - keep_prob_default),
Maxout(240, 240, 5),
)
self.L3 = nn.Sequential(
nn.Dropout(1 - keep_prob_default),
nn.Linear(240, 1),
nn.Sigmoid()
)
def forward(self, x):
x = self.L1(x)
x = self.L2(x)
x = self.L3(x)
return x