MCPcopy Create free account
hub / github.com/ActiveVisionLab/DFNet / autoencoder_vgg2

Class autoencoder_vgg2

script/feature/model.py:69–111  ·  view source on GitHub ↗

add skip connections

Source from the content-addressed store, hash-verified

67 return encode, decode
68
69class autoencoder_vgg2(nn.Module): # psnr 25.41
70 ''' add skip connections '''
71 def __init__(self):
72 super(autoencoder_vgg2, self).__init__()
73 conv1 = nn.Sequential(
74 nn.Conv2d(3, 16, 3, stride=2, padding=1),
75 nn.ReLU(inplace=True),
76 )
77 conv2 = nn.Sequential(
78 nn.Conv2d(16, 32, 3, stride=2, padding=1),
79 nn.ReLU(inplace=True),
80 )
81 conv3 = nn.Sequential(
82 nn.Conv2d(32, 64, 7)
83 )
84 self.encoder = nn.Sequential(
85 conv1, conv2, conv3
86 )
87
88 deconv1 = nn.Sequential(
89 nn.ConvTranspose2d(64, 32, 7),
90 nn.ReLU(inplace=True),
91 )
92 deconv2 = nn.Sequential(
93 nn.ConvTranspose2d(32, 16, 3, stride=2, padding=1, output_padding=1),
94 nn.ReLU(inplace=True),
95 )
96 deconv3 = nn.Sequential(
97 nn.ConvTranspose2d(16, 3, 3, stride=2, padding=1, output_padding=1),
98 nn.Tanh()
99 )
100 self.decoder = nn.Sequential(deconv1, deconv2, deconv3)
101 def forward(self, x):
102 feat1 = self.encoder[0](x)
103 feat2 = self.encoder[1](feat1)
104 x = self.encoder[2](feat2)
105
106 x = self.decoder[0](x)
107 x = x + feat2
108 x = self.decoder[1](x)
109 x = x + feat1
110 x = self.decoder[2](x)
111 return None, x
112
113class autoencoder_vgg3(nn.Module): # psnr: 37.77
114 ''' vgg encoder '''

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected