我们之前介绍了INFOGAN,今天运行代码复现效果。
Code for reproducing key results in the paper InfoGAN: Interpretable Representation Learning by Information Maximizing Generative Adversarial Nets by Xi Chen, Yan Duan, Rein Houthooft, John Schulman, Ilya Sutskever, Pieter Abbeel.
This project currently requires the dev version of TensorFlow available on Github:https://github.com/tensorflow/tensorflow. As of the release, the latest commit is 79174a.
In addition, please pip install
the following packages:
prettytensor
progressbar
python-dateutil
$ git clone git@github.com:openai/InfoGAN.git
$ docker run -v $(pwd)/InfoGAN:/InfoGAN -w /InfoGAN -it -p 8888:8888 gcr.io/tensorflow/tensorflow:r0.9rc0-devel
root@X:/InfoGAN# pip install -r requirements.txt
root@X:/InfoGAN# python launchers/run_mnist_exp.py
We provide the source code to run the MNIST example:
PYTHONPATH='.' python launchers/run_mnist_exp.py
You can launch TensorBoard to view the generated images:
tensorboard --logdir logs/mnist
我们直接使用文档的docker运行方法:
docker 安装参考: https://docs.docker.com/engine/installation/linux/ubuntulinux/#install
docker运行的秘钥运行前命令配置:
export DOCKER_OPTS="-H $DOCKER_HOST --tls --tlskey $DOCKER_CERT_PATH/server-key.pem --tlscert $DOCKER_CERT_PATH/server.pem --tlsverify --tlscacert $DOCKER_CERT_PATH/ca.pem "
alias docker="docker $DOCKER_OPTS "
docker run -v $(pwd)/a.InfoGAN:/a.InfoGAN -w /a.InfoGAN -it -p 8888:8888 gcr.io/tensorflow/tensorflow:r0.9rc0-devel 这一步如果为首次运行则会下载docker镜像然后运行进入镜像ssh终端。
原论文和程序中,mnist训练参数设置为10个类别的数字分类,和两个连续隐变量,测试中这两个隐变量分别学到了旋转和宽度特征
我们在配置中单独增加了另外两个连续变量,如下:
latent_spec = [
(Uniform(62), False),
(Categorical(10), True),
(Uniform(1, fix_std=True), True),
(Uniform(1, fix_std=True), True),
(Uniform(1, fix_std=True), True), #新加
(Uniform(1, fix_std=True), True), #新加
] 然后进行测试,看看程序能学到什么特征?
2 训练结果两个隐变量和4个隐变量的可视化对比:
第一行为10个分类,第二行为连续隐变量,
第三行是 第二个隐变量;第四行为新加的第一个隐变量
第五行为新加的第二个隐变量。
发现什么新特征了吗?