discriminator
Discriminator
Discriminator(
resolution: Resolution,
channels: Dict[Resolution, int] = default_channels,
blur_kernel: List[int] = [1, 3, 3, 1],
)
Bases: nn.Module
Discriminator module
Source code in stylegan2_torch/discriminator/__init__.py
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 |
|
__call__
class-attribute
__call__ = proxy(forward)
blocks
instance-attribute
blocks = nn.Sequential(
ConvBlock(1, channels[resolution], 1),
[
ResBlock(
channels[2**i],
channels[2**i - 1],
blur_kernel,
)
for i in range(self.n_layers, 2, -1)
],
)
final_conv
instance-attribute
final_conv = ConvBlock(channels[4] + 1, channels[4], 3)
final_linear
instance-attribute
final_linear = EqualLinear(channels[4], 1)
final_relu
instance-attribute
final_relu = EqualLeakyReLU(
channels[4] * 4 * 4, channels[4]
)
n_layers
instance-attribute
n_layers = int(math.log(resolution, 2))
stddev_feat
instance-attribute
stddev_feat = 1
stddev_group
instance-attribute
stddev_group = 4
forward
forward(input: Tensor, *, return_features: bool = False)
Source code in stylegan2_torch/discriminator/__init__.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
blocks
ConvBlock
ConvBlock(
in_channel: int, out_channel: int, kernel_size: int
)
Bases: nn.Sequential
Convolution in feature space
EqualConv2d: 2D convolution with equalized learning rate FusedLeakyReLU: LeakyReLU with a bias added before activation
Source code in stylegan2_torch/discriminator/blocks.py
19 20 21 22 23 24 25 26 27 28 29 30 |
|
__call__
__call__(input: Tensor) -> Tensor
Source code in stylegan2_torch/discriminator/blocks.py
32 33 |
|
DownConvBlock
DownConvBlock(
in_channel: int,
out_channel: int,
kernel_size: int,
down: int,
blur_kernel: List[int],
)
Bases: nn.Sequential
Downsampling convolution in feature space
Blur: Gaussian filter as low-pass filter for anti-aliasing + adjust tensor shape to preserve downsampled tensor shape EqualConv2d: 2D (downsampling) convolution with equalized learning rate FusedLeakyReLU: LeakyReLU with a bias added before activation
Source code in stylegan2_torch/discriminator/blocks.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
__call__
__call__(input: Tensor) -> Tensor
Source code in stylegan2_torch/discriminator/blocks.py
61 62 |
|
RGBDown
RGBDown(
in_channel: int,
out_channel: int,
kernel_size: int,
down: int,
blur_kernel: List[int],
)
Bases: nn.Sequential
Downsampling convolution in RGB space, hence no need nonlinearity
Blur: Gaussian filter as low-pass filter for anti-aliasing + adjust tensor shape to preserve downsampled tensor shape EqualConv2d: 2D (downsampling) convolution with equalized learning rate
Source code in stylegan2_torch/discriminator/blocks.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
__call__
__call__(input: Tensor) -> Tensor
Source code in stylegan2_torch/discriminator/blocks.py
89 90 |
|
ResBlock
ResBlock(
in_channel: int,
out_channel: int,
blur_kernel: List[int],
)
Bases: nn.Module
Residual block
ConvBlock + DownConvBlock: Convolution + downsampling RGBDown: Skip connection from higher (double) resolution RGB image
Source code in stylegan2_torch/discriminator/blocks.py
101 102 103 104 105 106 107 108 |
|
__call__
class-attribute
__call__ = proxy(forward)
conv
instance-attribute
conv = ConvBlock(in_channel, in_channel, 3)
down_conv
instance-attribute
down_conv = DownConvBlock(
in_channel,
out_channel,
3,
down=2,
blur_kernel=blur_kernel,
)
skip
instance-attribute
skip = RGBDown(
in_channel,
out_channel,
1,
down=2,
blur_kernel=blur_kernel,
)
forward
forward(input: Tensor) -> Tensor
Source code in stylegan2_torch/discriminator/blocks.py
110 111 112 113 114 115 116 |
|