-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfullyConnectedLargeModel.py
53 lines (42 loc) · 1.28 KB
/
fullyConnectedLargeModel.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
from __future__ import division
import torch.nn as nn
class Encoder(nn.Module):
def __init__(self,x_dim, z_dim):
"""
Encoder initializer
:param x_dim: dimension of the input
:param z_dim: dimension of the latent representation
"""
super(Encoder, self).__init__()
self.model = nn.Sequential(
nn.Linear(int(x_dim),512),
nn.Tanh(),
nn.Linear(512,512),
nn.Tanh(),
nn.Linear(512,512),
nn.Tanh(),
nn.Linear(512, z_dim),
)
def forward(self, img):
out = self.model(img)
return out
class Decoder(nn.Module):
def __init__(self,x_dim, z_dim):
"""
Encoder initializer
:param x_dim: dimension of the input
:param z_dim: dimension of the latent representation
"""
super(Decoder, self).__init__()
self.model = nn.Sequential(
nn.Linear(z_dim,512),
nn.Tanh(),
nn.Linear(512,512),
nn.Tanh(),
nn.Linear(512,512),
nn.Tanh(),
nn.Linear(512,x_dim)
)
def forward(self, z):
img= self.model(z)
return img