This commit is contained in:
chenxuanhong
2022-01-10 15:03:58 +08:00
parent 573689a591
commit 3783ef0e75
57 changed files with 9520 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
import torch
from torch import nn
class DeConv(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size = 3, upsampl_scale = 2):
super().__init__()
self.upsampling = nn.UpsamplingNearest2d(scale_factor=upsampl_scale)
padding_size = int((kernel_size -1)/2)
# self.same_padding = nn.ReflectionPad2d(padding_size)
self.conv = nn.Conv2d(in_channels = in_channels ,padding=padding_size, out_channels = out_channels , kernel_size= kernel_size, bias= False)
self.__weights_init__()
def __weights_init__(self):
nn.init.xavier_uniform_(self.conv.weight)
def forward(self, input):
h = self.upsampling(input)
# h = self.same_padding(h)
h = self.conv(h)
return h