gpt4 book ai didi

python-3.x - 修改 Chainer DCGAN 模型的输入图像的大小

转载 作者:行者123 更新时间:2023-11-30 08:45:28 26 4
gpt4 key购买 nike

我正在使用位于 https://github.com/chainer/chainer/blob/master/examples/dcgan/train_dcgan.py 的 Chainer DCGAN 示例文件。它适用于 32x32 图像,但对于其他分辨率,README.md 指示修改 net.py 中的网络架构。

据我从阅读文档中了解到,训练图像的大小作为参数发送到 Generator 类的构造函数,如 Bottom_width 和 ch。这是 32x32 的代码。

class Generator(chainer.Chain):    def __init__(self, n_hidden, bottom_width=4, ch=512, wscale=0.02):

我很困惑如何将其转换为 32x32,以及如何将其修改为其他分辨率。任何帮助将不胜感激。

最佳答案

您可以通过了解 Devolving2D 的行为来计算它。在 net.py , 3 Devolve2D 层(self.dc1self.dc2self.dc3)使用 stride=2 定义> (L.Devolving2D 的第四个参数),使输入高度/宽度加倍。

因此,输出大小将为 bottom_size * 2^3,当 bottom_size=4 时结果为 32。

例如,如果您想获得 64x64 图像,您可以为生成器和鉴别器设置 bottom_size=8 (但您需要 64x64 图像作为真实数据,而不是 cifar-100,即 32x32图片)。

具体输入输出大小关系请引用官方文档。

关于python-3.x - 修改 Chainer DCGAN 模型的输入图像的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53928235/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com