{"id":21961441,"url":"https://github.com/lilianweng/unified-gan-tensorflow","last_synced_at":"2025-04-23T20:20:49.025Z","repository":{"id":41493421,"uuid":"102243237","full_name":"lilianweng/unified-gan-tensorflow","owner":"lilianweng","description":"A Tensorflow implementation of GAN, WGAN and WGAN with gradient penalty.","archived":false,"fork":false,"pushed_at":"2018-08-27T16:31:16.000Z","size":1689,"stargazers_count":116,"open_issues_count":1,"forks_count":34,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-30T03:11:07.490Z","etag":null,"topics":["dcgan-tensorflow","gan","tensorflow","wgan","wgan-gp"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lilianweng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-03T05:27:06.000Z","updated_at":"2025-01-15T21:39:39.000Z","dependencies_parsed_at":"2022-09-08T09:11:03.457Z","dependency_job_id":null,"html_url":"https://github.com/lilianweng/unified-gan-tensorflow","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lilianweng%2Funified-gan-tensorflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lilianweng%2Funified-gan-tensorflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lilianweng%2Funified-gan-tensorflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lilianweng%2Funified-gan-tensorflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lilianweng","download_url":"https://codeload.github.com/lilianweng/unified-gan-tensorflow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250506500,"owners_count":21441791,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dcgan-tensorflow","gan","tensorflow","wgan","wgan-gp"],"created_at":"2024-11-29T10:15:18.818Z","updated_at":"2025-04-23T20:20:48.974Z","avatar_url":"https://github.com/lilianweng.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Original, Wasserstein, and Wasserstein-Gradient-Penalty DCGAN\n\n(\\*) This repo is a modification of [carpedm20/DCGAN-tensorflow](https://github.com/carpedm20/DCGAN-tensorflow).\n\n(\\*) The full credit of the model structure design goes to [carpedm20/DCGAN-tensorflow](https://github.com/carpedm20/DCGAN-tensorflow). \n\nI started with [carpedm20/DCGAN-tensorflow](https://github.com/carpedm20/DCGAN-tensorflow) because its DCGAN implementation is not fixed for one dataset, which is not a common setting. Most WGAN and WGAN-GP implementations only work on 'mnist' or one given dataset.\n\n\n\n### Modifications\n\nA couple of modifications I've made that could be helpful to people who try to implement GAN on their own for the first time.\n1. Added `model_type` which could be one of 'GAN' (original), 'WGAN' (Wasserstein distance as loss), and 'WGAN_GP' (Wasserstein distance as loss function with gradient penalty), each corresponding to one variation of GAN model.\n2. `UnifiedDCGAN` can build and train the graph differently according to `model_type`.\n3. Some model methods were reconstructed so that the code is easier to read through.\n4. Many comments were added for important, or potential confusing functions, like conv and deconv operations in `ops.py`.\n\nThe `download.py` file stays same as in [carpedm20/DCGAN-tensorflow](https://github.com/carpedm20/DCGAN-tensorflow). I keep this file in the repo for the sake of easily fetching dataset for testing.\n\n\n### Reading\n\nIf you are interested in the math behind the loss functions of GAN and WGAN, read **[here](https://lilianweng.github.io/lil-log/2017/08/20/from-GAN-to-WGAN.html)**.\n\n\n### Related Papers\n\n- Goodfellow, Ian, et al. [\"Generative adversarial nets.\"](https://arxiv.org/pdf/1406.2661.pdf) NIPS, 2014.\n- Martin Arjovsky, Soumith Chintala, and Léon Bottou. [\"Wasserstein GAN.\"](https://arxiv.org/pdf/1701.07875.pdf) arXiv preprint arXiv:1701.07875 (2017).\n- Ishaan Gulrajani, Faruk Ahmed, Martin Arjovsky, Vincent Dumoulin, Aaron Courville. [Improved training of wasserstein gans.](https://arxiv.org/pdf/1704.00028.pdf) arXiv preprint arXiv:1704.00028 (2017).\n\n### Test Runs:\n\n```\n(left) python main.py --dataset=mnist --model_type=GAN --batch_size=64 --input_height=28 --output_height=28 --max_iter=10000 --learning_rate=0.0002 --train\n(middle) python main.py --dataset=mnist --model_type=WGAN --batch_size=64 --input_height=28 --output_height=28 --d_iter=5 --max_iter=10000 --learning_rate=0.00005 --train\n(right) python main.py --dataset=mnist --model_type=WGAN_GP --batch_size=64 --input_height=28 --output_height=28 --d_iter=5 --max_iter=10000 --learning_rate=0.0001 --train\n```\n![](demos/mnist_GAN.gif \"GAN on mnist\")\u0026nbsp;![](demos/mnist_WGAN.gif \"WGAN on mnist\")\u0026nbsp;![](demos/mnist_WGAN_GP.gif \"WGAN with gradient penalty on mnist\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flilianweng%2Funified-gan-tensorflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flilianweng%2Funified-gan-tensorflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flilianweng%2Funified-gan-tensorflow/lists"}