MCPcopy Create free account
hub / github.com/KeepTryingTo/Pytorch-GAN / UpsampleBlock

Class UpsampleBlock

SRGAN/models.py:33–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31
32#采用PixelShuffle进行上采样
33class UpsampleBlock(torch.nn.Module):
34 def __init__(self,in_channels,scale_factor):
35 super(UpsampleBlock, self).__init__()
36 self.conv = torch.nn.Conv2d(in_channels,in_channels*scale_factor**2,kernel_size = (3,3),stride = (1,1),padding=(1,1))
37 #(in_channels * 4,H,W) => (in_channels,H*2,W*2)
38 self.ps = torch.nn.PixelShuffle(scale_factor)
39 self.act = torch.nn.PReLU(num_parameters=in_channels)
40 def forward(self,x):
41 out = self.act(self.ps(self.conv(x)))
42 return out
43
44
45class ResidualBlock(torch.nn.Module):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected