GANs/CycleGAN_Zhu_et_al_2017/model.py
def make_conv(self, in_size, out_size, encode, instance_norm, activation, drop_out):
        """Convolutional blocks of the Generator and the Discriminator.

        :param in_size: number of input filters
        :type in_size: int
        :param out_size: number of output filters
        :type out_size: int
        :param encode: apply convolution to downsaple
        :type encode: bool
        :param instance_norm: apply instance norm
        :type instance_norm: bool
        :param activation: activation function
        :type activation: str
        :param drop_out: apply 0.5 dropout
        :type drop_out: bool
        :return: the convolutional block
        :rtype: nn.Sequential

        Let Ck denote a Convolution-InstanceNorm-ReLU block with k filters.
        CDk denotes a Convolution-BtachNorm-Dropout-ReLU block with 50% dropout.
        All convolutions are 4 x 4 spatial filters with stride 2. Convolutions in
        the encoder and discriminator downsample by a factor of 2, whereas in the
        decoder they upsample by a factor of 2.
        """
        block = [nn.Conv2d(in_size, out_size,
                           kernel_size=4, stride=2, padding=1,
                           padding_mode="reflect",
                           bias=False if instance_norm else True)
                 if encode else
                 nn.ConvTranspose2d(in_size, out_size,
                                    kernel_size=4, stride=2, padding=1,
                                    bias=False if instance_norm else True)]

        if instance_norm:
            block.append(nn.InstanceNorm2d(out_size, affine=True))
        if activation == "leaky":
            block.append(nn.LeakyReLU(0.2, inplace=True))
        elif activation == "sigmoid":
            block.append(nn.Sigmoid())
        elif activation == "tanh":
            block.append(nn.Tanh())
        elif activation == "relu":
            block.append(nn.ReLU())
        if drop_out:
            block.append(nn.Dropout(0.5))

        return nn.Sequential(*block)
Convolutional blocks of the Generator and the Discriminator.

        :param in_size: number of input filters
        :type in_size: int
        :param out_size: number of output filters
        :type out_size: int
        :param encode: apply convolution to downsaple
        :type encode: bool
        :param instance_norm: apply instance norm
        :type instance_norm: bool
        :param activation: activation function
        :type activation: str
        :param drop_out: apply 0.5 dropout
        :type drop_out: bool
        :return: the convolutional block
        :rtype: nn.Sequential

        Let Ck denote a Convolution-InstanceNorm-ReLU block with k filters.
        CDk denotes a Convolution-BtachNorm-Dropout-ReLU block with 50% dropout.
        All convolutions are 4 x 4 spatial filters with stride 2. Convolutions in
        the encoder and discriminator downsample by a factor of 2, whereas in the
        decoder they upsample by a factor of 2.
        
Convolutional blocks of the Generator and the Discriminator.
Convolutional blocks of the Generator and the Discriminator .
def make_conv(self, in_size, out_size, encode, instance_norm, activation, drop_out):
        block = [nn.Conv2d(in_size, out_size,
                           kernel_size=4, stride=2, padding=1,
                           padding_mode="reflect",
                           bias=False if instance_norm else True)
                 if encode else
                 nn.ConvTranspose2d(in_size, out_size,
                                    kernel_size=4, stride=2, padding=1,
                                    bias=False if instance_norm else True)]
        if instance_norm:
            block.append(nn.InstanceNorm2d(out_size, affine=True))
        if activation == "leaky":
            block.append(nn.LeakyReLU(0.2, inplace=True))
        elif activation == "sigmoid":
            block.append(nn.Sigmoid())
        elif activation == "tanh":
            block.append(nn.Tanh())
        elif activation == "relu":
            block.append(nn.ReLU())
        if drop_out:
            block.append(nn.Dropout(0.5))
        return nn.Sequential(*block)
def make_conv ( self , in_size , out_size , encode , instance_norm , activation , drop_out ) : block = [ nn . Conv2d ( in_size , out_size , kernel_size = 4 , stride = 2 , padding = 1 , padding_mode = "reflect" , bias = False if instance_norm else True ) if encode else nn . ConvTranspose2d ( in_size , out_size , kernel_size = 4 , stride = 2 , padding = 1 , bias = False if instance_norm else True ) ] if instance_norm : block . append ( nn . InstanceNorm2d ( out_size , affine = True ) ) if activation == "leaky" : block . append ( nn . LeakyReLU ( 0.2 , inplace = True ) ) elif activation == "sigmoid" : block . append ( nn . Sigmoid ( ) ) elif activation == "tanh" : block . append ( nn . Tanh ( ) ) elif activation == "relu" : block . append ( nn . ReLU ( ) ) if drop_out : block . append ( nn . Dropout ( 0.5 ) ) return nn . Sequential ( * block )
Convolutional blocks of the Generator and the Discriminator.
Convolutional blocks of the Generator and the Discriminator .
"""Convolutional blocks of the Generator and the Discriminator.

        :param in_size: number of input filters
        :type in_size: int
        :param out_size: number of output filters
        :type out_size: int
        :param encode: apply convolution to downsaple
        :type encode: bool
        :param instance_norm: apply instance norm
        :type instance_norm: bool
        :param activation: activation function
        :type activation: str
        :param drop_out: apply 0.5 dropout
        :type drop_out: bool
        :return: the convolutional block
        :rtype: nn.Sequential

        Let Ck denote a Convolution-InstanceNorm-ReLU block with k filters.
        CDk denotes a Convolution-BtachNorm-Dropout-ReLU block with 50% dropout.
        All convolutions are 4 x 4 spatial filters with stride 2. Convolutions in
        the encoder and discriminator downsample by a factor of 2, whereas in the
        decoder they upsample by a factor of 2.
        """
the convolutional block
the convolutional block
nn.Sequential
Let Ck denote a Convolution-InstanceNorm-ReLU block with k filters.
CDk denotes a Convolution-BtachNorm-Dropout-ReLU block with 50% dropout.
All convolutions are 4 x 4 spatial filters with stride 2. Convolutions in
the encoder and discriminator downsample by a factor of 2, whereas in the
decoder they upsample by a factor of 2.
self
in_size
number of input filters
number of input filters
out_size
number of output filters
number of output filters
encode
apply convolution to downsaple
apply convolution to downsaple
instance_norm
apply instance norm
apply instance norm
activation
None
drop_out
apply 0.5 dropout
apply 0 . 5 dropout