Giter VIP home page Giter VIP logo

dirac-gan's Introduction

Dirac-GAN

License: MIT

This repository implements (PyTorch) the Dirac-GAN proposed in the paper "Which Training Methods for GANs do actually Converge?" by Mescheder et al. [1]. The original implementation of the authors can be found here.

This work was done as part of the lecture Deep Generative Models at TU Darmstadt held by Dr. Anirban Mukhopadhyay.

Parts of this implementation are taken from my recent mode collapse example repository.

Standard GAN loss Non-saturating GAN loss Wasserstein GAN
1 2 3
Wasserstein GAN loss + GP Least squares GAN Hinge GAN
5 6 7
DRAGAN loss
5

This repository implements the following GAN losses and regularizers.

Method Generator loss Discriminator loss
Original GAN loss
Non-saturating GAN loss
Wasserstein GAN loss
Wasserstein GAN loss + grad. pen.
Least squares GAN loss
Hinge GAN
DRAGAN
Method Generator loss
regularization
regularization
regularization

Dependencies

Dirac-GAN is written in PyTorch 1.8.1. No GPU is required! All additional dependencies can be seen in the requirements.txt file. To install all dependencies simply run:

pip install -r requirements.txt

Older version of PyTorch may also allows running the code without issues.

Usage

The implementation provides a simple GUI to run all Dirac-GAN experiments with different settings. Simply run:

python main.py

Set the desired parameters in the GUI and click on "Run training" to perform training. This could take a few seconds. If the training is finished all results are plotted and shown.

References

[1] @inproceedings{Mescheder2018,
    title={Which training methods for GANs do actually converge?},
    author={Mescheder, Lars and Geiger, Andreas and Nowozin, Sebastian},
    booktitle={International conference on machine learning},
    pages={3481--3490},
    year={2018},
    organization={PMLR}
}

dirac-gan's People

Contributors

christophreich1996 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dirac-gan's Issues

R1 regularization

Thanks for creating this. Your code helped me to understand and implement R1 regularization.

Here is a patch to allow the main window to be resized with the widgets being laid out automatically:

--- a/main.py
+++ b/main.py
@@ -2,7 +2,7 @@ import sys
 import matplotlib
 
 matplotlib.use('Qt5Agg')
-from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QComboBox, QCheckBox, QSizePolicy
+from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QComboBox, QCheckBox, QSizePolicy, QWidget, QVBoxLayout, QHBoxLayout, QSpacerItem
 from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
 from matplotlib.figure import Figure
 import torch
@@ -103,7 +103,6 @@ class App(QMainWindow):
         # Make list box to choose regularization
         self.instance_noise_box = QCheckBox("Instance noise", self)
         self.instance_noise_box.resize(300, 50)
-        self.instance_noise_box.move(self.width - 300, self.height - 200)
         # Make list box to choose regularization
         self.regularization_box = QComboBox(self)
         self.regularization_box.addItem("None")
@@ -111,7 +110,6 @@ class App(QMainWindow):
         self.regularization_box.addItem("RLC")
         self.regularization_box.addItem("R2 gradient penalty")
         self.regularization_box.resize(300, 50)
-        self.regularization_box.move(self.width - 300, self.height - 150)
         # Make list box to choose GAN loss
         self.gan_list_box = QComboBox(self)
         self.gan_list_box.addItem("Standard GAN")
@@ -122,13 +120,26 @@ class App(QMainWindow):
         self.gan_list_box.addItem("DRAGAN")
         self.gan_list_box.addItem("Hinge GAN")
         self.gan_list_box.resize(300, 50)
-        self.gan_list_box.move(self.width - 300, self.height - 100)
         # Make run button
         run_button = QPushButton("button", self)
         run_button.setText("Run training")
         run_button.resize(300, 50)
-        run_button.move(self.width - 300, self.height - 50)
         run_button.clicked.connect(self.__train)
+
+        vlayout = QVBoxLayout()
+        vlayout.addItem(QSpacerItem(0, 0, QSizePolicy.Fixed, QSizePolicy.Expanding));
+        vlayout.addWidget(self.instance_noise_box)
+        vlayout.addWidget(self.regularization_box)
+        vlayout.addWidget(self.gan_list_box)
+        vlayout.addWidget(run_button)
+
+        hlayout = QHBoxLayout()
+        hlayout.addWidget(self.dynamic_plot)
+        hlayout.addLayout(vlayout)
+
+        widget = QWidget()
+        widget.setLayout(hlayout)
+        self.setCentralWidget(widget)
         # Show everything
         self.show()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.