-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdvae.py
32 lines (28 loc) · 1.01 KB
/
dvae.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
from utils import *
class dVAE(nn.Module):
def __init__(self, vocab_size, img_channels):
super().__init__()
self.encoder = nn.Sequential(
Conv2dBlock(img_channels, 64, 4, 4),
Conv2dBlock(64, 64, 1, 1),
Conv2dBlock(64, 64, 1, 1),
Conv2dBlock(64, 64, 1, 1),
Conv2dBlock(64, 64, 1, 1),
Conv2dBlock(64, 64, 1, 1),
Conv2dBlock(64, 64, 1, 1),
conv2d(64, vocab_size, 1)
)
self.decoder = nn.Sequential(
Conv2dBlock(vocab_size, 64, 1),
Conv2dBlock(64, 64, 3, 1, 1),
Conv2dBlock(64, 64, 1, 1),
Conv2dBlock(64, 64, 1, 1),
Conv2dBlock(64, 64 * 2 * 2, 1),
nn.PixelShuffle(2),
Conv2dBlock(64, 64, 3, 1, 1),
Conv2dBlock(64, 64, 1, 1),
Conv2dBlock(64, 64, 1, 1),
Conv2dBlock(64, 64 * 2 * 2, 1),
nn.PixelShuffle(2),
conv2d(64, img_channels, 1),
)