Exemplo n.º 1
0
    def __init__(self,
                 num_features=32,
                 dim_z=128,
                 bottom_width=7,
                 activation=F.relu,
                 num_classes=0,
                 distribution='normal'):
        super(Omniglot_Generator, self).__init__()
        self.num_features = num_features
        self.dim_z = dim_z
        self.bottom_width = bottom_width
        self.activation = activation
        self.num_classes = num_classes
        self.distribution = distribution

        self.l1 = nn.Linear(dim_z, 4 * num_features * bottom_width**2)

        self.block2 = Block(num_features * 4,
                            num_features * 2,
                            activation=activation,
                            upsample=True,
                            num_classes=num_classes)
        self.block3 = Block(num_features * 2,
                            num_features,
                            activation=activation,
                            upsample=True,
                            num_classes=num_classes)
        self.b4 = nn.BatchNorm2d(num_features)
        self.conv4 = nn.Conv2d(num_features, 1, 1, 1)
Exemplo n.º 2
0
    def __init__(self, num_features=64, dim_z=128, bottom_width=4,
                 activation=F.relu, num_classes=0, distribution='normal'):
        super(VGG_Generator, self).__init__()
        self.num_features = num_features
        self.dim_z = dim_z
        self.bottom_width = bottom_width
        self.activation = activation
        self.num_classes = num_classes
        self.distribution = distribution

        self.l1 = nn.Linear(dim_z, 4 * num_features * bottom_width ** 2)

        self.block2 = Block(num_features * 4, num_features * 2,
                            activation=activation, upsample=True,
                            num_classes=num_classes)
        self.block3 = Block(num_features * 2, num_features,
                            activation=activation, upsample=True,
                            num_classes=num_classes)
        self.block4 = Block(num_features, num_features // 2,
                            activation=activation, upsample=True,
                            num_classes=num_classes)

        self.block5 = Self_Attn(num_features // 2)

        self.block6 = Block(num_features // 2, num_features // 4,
                            activation=activation, upsample=True,
                            num_classes=num_classes)

        self.block7 = Self_Attn(num_features // 4)

        self.b4 = nn.BatchNorm2d(num_features // 4)
        self.conv4 = nn.Conv2d(num_features // 4, 3, 1, 1)
Exemplo n.º 3
0
    def __init__(self,
                 num_features=64,
                 dim_z=128,
                 bottom_width=4,
                 activation=F.relu,
                 num_classes=0,
                 distribution='normal'):
        super(ResNetGenerator, self).__init__()
        self.num_features = num_features
        self.dim_z = dim_z
        self.bottom_width = bottom_width
        self.activation = activation
        self.num_classes = num_classes
        self.distribution = distribution

        self.l1 = nn.Linear(dim_z, 16 * num_features * bottom_width**2)

        self.block2 = Block(num_features * 16,
                            num_features * 16,
                            activation=activation,
                            upsample=True,
                            num_classes=num_classes)
        self.block3 = Block(num_features * 16,
                            num_features * 8,
                            activation=activation,
                            upsample=True,
                            num_classes=num_classes)
        self.block4 = Block(num_features * 8,
                            num_features * 4,
                            activation=activation,
                            upsample=True,
                            num_classes=num_classes)
        self.block5 = Block(num_features * 4,
                            num_features * 2,
                            activation=activation,
                            upsample=True,
                            num_classes=num_classes)
        self.block6 = Block(num_features * 2,
                            num_features,
                            activation=activation,
                            upsample=True,
                            num_classes=num_classes)
        self.b7 = nn.BatchNorm2d(num_features)
        self.conv7 = nn.Conv2d(num_features, 3, 1, 1)