equalized_lr
Blur
Blur(blur_kernel: List[int], factor: int, kernel_size: int)
Bases: nn.Module
Upsample (factor > 0)
Applied after a transpose convolution of stride U and kernel size K
Apply blurring FIR filter (before / after) a (downsampling / upsampling) op
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
Tensor
|
(N, C, (H - 1) * U + K - 1 + 1, (W - 1) * U + K - 1 + 1) |
required |
blur_kernel |
Tensor
|
FIR filter |
required |
factor |
int
|
U. Defaults to 2. |
required |
kernel_size |
int
|
K. Defaults to 3. |
required |
Returns:
Name | Type | Description |
---|---|---|
Tensor | (N, C, H * U, W * U) |
Downsample (factor < 0)
Applied before a convolution of stride U and kernel size K
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
Tensor
|
(N, C, H, W) |
required |
blur_kernel |
Tensor
|
FIR filter |
required |
factor |
int
|
U. Defaults to 2. |
required |
kernel_size |
int
|
K. Defaults to 3. |
required |
Returns:
Name | Type | Description |
---|---|---|
Tensor | (N, C, H - (U + 1) + K - 1, H - (U + 1) + K - 1) |
Source code in stylegan2_torch/equalized_lr.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
__call__
class-attribute
__call__ = proxy(forward)
kernel
instance-attribute
kernel: Tensor = None
pad
instance-attribute
pad = (pad0, pad1)
forward
forward(input: Tensor) -> Tensor
Source code in stylegan2_torch/equalized_lr.py
171 172 |
|
EqualConv2d
EqualConv2d(
in_channel: int,
out_channel: int,
kernel_size: int,
stride: int = 1,
padding: int = 0,
bias: bool = True,
)
Bases: nn.Module
Conv2d with equalized learning rate
Source code in stylegan2_torch/equalized_lr.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
__call__
class-attribute
__call__ = proxy(forward)
bias
instance-attribute
bias = Parameter(torch.zeros(out_channel)) if bias else None
padding
instance-attribute
padding = padding
scale
instance-attribute
scale = 1 / math.sqrt(in_channel * kernel_size ** 2)
stride
instance-attribute
stride = stride
weight
instance-attribute
weight = Parameter(
torch.randn(
out_channel, in_channel, kernel_size, kernel_size
)
)
__repr__
__repr__() -> str
Source code in stylegan2_torch/equalized_lr.py
51 52 53 54 55 |
|
forward
forward(input: Tensor) -> Tensor
Source code in stylegan2_torch/equalized_lr.py
42 43 44 45 46 47 48 49 |
|
EqualLeakyReLU
EqualLeakyReLU(
in_dim: int, out_dim: int, lr_mult: float = 1
)
Bases: nn.Module
Leaky ReLU with equalized learning rate
Source code in stylegan2_torch/equalized_lr.py
99 100 101 102 103 104 105 106 107 108 109 |
|
__call__
class-attribute
__call__ = proxy(forward)
bias
instance-attribute
bias = Parameter(torch.zeros(out_dim))
lr_mult
instance-attribute
lr_mult = lr_mult
scale
instance-attribute
scale = 1 / math.sqrt(in_dim) * lr_mult
weight
instance-attribute
weight = Parameter(
torch.randn(out_dim, in_dim).div_(lr_mult)
)
__repr__
__repr__() -> str
Source code in stylegan2_torch/equalized_lr.py
115 116 117 118 |
|
forward
forward(input: Tensor) -> Tensor
Source code in stylegan2_torch/equalized_lr.py
111 112 113 |
|
EqualLinear
EqualLinear(
in_dim: int,
out_dim: int,
bias_init: int = 0,
lr_mult: float = 1,
)
Bases: nn.Module
Linear with equalized learning rate
Source code in stylegan2_torch/equalized_lr.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
__call__
class-attribute
__call__ = proxy(forward)
bias
instance-attribute
bias = Parameter(torch.zeros(out_dim).fill_(bias_init))
lr_mult
instance-attribute
lr_mult = lr_mult
scale
instance-attribute
scale = 1 / math.sqrt(in_dim) * lr_mult
weight
instance-attribute
weight = Parameter(
torch.randn(out_dim, in_dim).div_(lr_mult)
)
__repr__
__repr__() -> str
Source code in stylegan2_torch/equalized_lr.py
86 87 88 89 |
|
forward
forward(input: Tensor) -> Tensor
Source code in stylegan2_torch/equalized_lr.py
83 84 |
|