-
Notifications
You must be signed in to change notification settings - Fork 2
/
fullyConnectedModel.py
52 lines (37 loc) · 1.2 KB
/
fullyConnectedModel.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
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_enc = nn.Sequential(
nn.Linear(int(x_dim),512),
nn.ReLU(),
)
# compute mean and Laplacian weights
self.fc= nn.Linear(512, z_dim)
def forward(self, x):
# 2 hidden layers encoder
x = self.model_enc(x)
z= self.fc(x)
return z
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.ReLU(),
nn.Linear(512,x_dim),
)
def forward(self, z):
img= self.model(z)
return img