基于 Pytorch 的 TorchGAN开源了!
source link: http://ccc013.github.io/2019/02/01/资源-基于-Pytorch-的-TorchGAN开源了!/?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
之前推荐过一个基于 TensorFlow 的 GAN 框架— 谷歌开源的 GAN 库—TFGAN 。
而最近也有一个新的 GAN 框架工具,并且是基于 Pytorch 实现的,项目地址如下:
https://github.com/torchgan/torchgan
对于习惯使用 Pytorch 框架的同学,现在可以采用这个开源项目快速搭建一个 GAN 网络模型了!
目前该开源项目有 400+ 星,它给出了安装的教程、API 文档以及使用教程,文档的地址如下:
https://torchgan.readthedocs.io/en/latest/
安装
对于 TorchGAN 的安装,官网给出 3 种方法,但实际上目前仅支持两种安装方式,分别是 pip
方式安装以及源码安装,采用 conda
安装的方法目前还不支持。
Pip 安装方法
安装最新的发布版本的命令如下:
$ pip3 install torchgan
而如果是最新版本:
$ pip3 install git+https://github.com/torchgan/torchgan.git
Conda 安装
这是目前版本还不支持的安装方式,将会在 v0.1
版本实现这种安装方法。
源码方式安装
按照下列命令的顺序执行来进行从源码安装
$ git clone https://github.com/torchgan/torchgan $ cd torchgan $ python setup.py install
依赖库
必须按照的依赖库:
- Numpy
- Pytorch 0.4.1
- Torchvision
可选
- TensorboardX:主要是为了采用
Tensorboard
来观察和记录实验结果。安装通过命令pip install tensorboardX
- Visdom:为了采用
Xisdom
进行记录。安装通过命令pip install visdom
API 文档
API 的文档目录如下:
从目录主要分为以下几个大类:
- torchgan.layers:包含当前常用的用于构建 GAN 结构的一些网络层,包括残差块,Self-Attention,谱归一化(Spectral Normalization)等等
- torchgan.logging:提供了很强的可视化工具接口,包括对损失函数、梯度、测量标准以及生成图片的可视化等
- torchgan.losses:常见的训练 GANs 模型的损失函数,包括原始的对抗损失、最小二乘损失、WGAN的损失函数等;
- torchgan.metrics:主要是提供了不同的评判测量标准
- torchgan.models:包含常见的 GAN 网络结构,可以直接使用并且也可以进行拓展,包括 DCGAN、cGAN等
- torchgan.trainer:主要是提供训练模型的函数接口
教程
教程部分如下所示:
教程给出了几个例子,包括 DCGAN、Self-Attention GAN、CycleGAN 例子,以及如何自定义损伤的方法。
对于 Self-Attention GAN,还提供了一个在谷歌的 Colab 运行的例子,查看链接:
https://torchgan.readthedocs.io/en/latest/tutorials/sagan.html
小结
最后,再给出 Github 项目的链接和文档的对应链接地址:
https://github.com/torchgan/torchgan
https://torchgan.readthedocs.io/en/latest/index.html
欢迎关注我的微信公众号—机器学习与计算机视觉,或者扫描下方的二维码,大家一起交流,学习和进步!
之前分享的资源和教程文章有:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK