【笔记】LAP——GAN:拉普拉斯金字塔第k层等于高斯金字塔第k层减去高斯金字塔第k+1层的上采样;第k层重建需要用它的的k+1层上采样加上拉普拉斯金字塔第k层

使用对抗网络的拉普拉斯金字塔的深度生成图像模型

Deep Generative Image Models using a Laplacian Pyramid of Adversarial Networks

lass GeneratorTop(nn.Module):
    def __init__(self, z_dim=100, out_width=8):
        super().__init__()
        self.out_width = out_width
        self.layers = nn.Sequential(nn.Linear(z_dim, z_dim*10),
                                    nn.Linear(z_dim*10, z_dim*20),
                                    nn.Linear(z_dim*20, self.out_width*self.out_width*3))
        
    def forward(self, x):
        return self.layers(x).view(-1, self.out_width, self.out_width, 3)

class G2(nn.Module):
    def __init__(self, in_dim=4, out_width=16):
        super().__init__()
        self.layers = nn.Sequential(nn.Conv2d(in_dim, 128, 3, 1, 1),
                                    nn.ReLU(),
                                    nn.Conv2d(128, 128, 3, 1, 1),
                                    nn.ReLU(),
                                    nn.Conv2d(128, 3, 3, 1, 1))

    def forward(self, x):
        return self.layers(x)

class D2(nn.Module):
    def __init__(self, in_dim=3, in_width=16):
        super().__init__()
        self.front_layers = nn.Sequential(nn.Conv2d(in_dim, 128, 3, 2, 1),
                                          nn.ReLU(),
                                          nn.Conv2d(128, 128, 3, 2, 1),
                                          nn.ReLU())
        # 卷积以后的特征图长宽
        current_width = int(in_width/4)
        # 定义最后用于分类的全连接层
        self.last_layer = nn.Linear(128*current_width*current_width, 1)
        self.sigmoid = nn.Sigmoid()

    def forward(self, x):
        temp = self.front_layers(x)
        # 全连接层的输入需要是2D的
        temp = temp.view(temp.size(0), -1)
        out = self.sigmoid(self.last_layer(temp))
        return out

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值