File size: 1,452 Bytes
8e1e3ba | 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 | import torch.nn as nn
class Decoder(nn.Module):
def __init__(self):
super().__init__()
self.layer = nn.Sequential(
nn.ReflectionPad2d(1),
nn.Conv2d(512, 256, kernel_size=3),
nn.ReLU(inplace=True),
nn.Upsample(scale_factor=2, mode='nearest'),
nn.ReflectionPad2d(1),
nn.Conv2d(256, 256, kernel_size=3),
nn.ReLU(inplace=True),
nn.ReflectionPad2d(1),
nn.Conv2d(256, 256, kernel_size=3),
nn.ReLU(inplace=True),
nn.ReflectionPad2d(1),
nn.Conv2d(256, 256, kernel_size=3),
nn.ReLU(inplace=True),
nn.ReflectionPad2d(1),
nn.Conv2d(256, 128, kernel_size=3),
nn.ReLU(inplace=True),
nn.Upsample(scale_factor=2, mode='nearest'),
nn.ReflectionPad2d(1),
nn.Conv2d(128, 128, kernel_size=3),
nn.ReLU(inplace=True),
nn.ReflectionPad2d(1),
nn.Conv2d(128, 64, kernel_size=3),
nn.ReLU(inplace=True),
nn.Upsample(scale_factor=2, mode='nearest'),
nn.ReflectionPad2d(1),
nn.Conv2d(64, 64, kernel_size=3),
nn.ReLU(inplace=True),
nn.ReflectionPad2d(1),
nn.Conv2d(64, 3, kernel_size=3)
)
def forward(self, x):
return self.layer(x)
|