Code Monkey home page Code Monkey logo

san's Introduction

Slicing Adversarial Network (SAN) [ICLR 2024]

This repository contains the official PyTorch implementation of "SAN: Inducing Metrizability of GAN with Discriminative Normalized Linear Layer" (arXiv 2301.12811). Please cite [1] in your work when using this code in your experiments.

Abstract: Generative adversarial networks (GANs) learn a target probability distribution by optimizing a generator and a discriminator with minimax objectives. This paper addresses the question of whether such optimization actually provides the generator with gradients that make its distribution close to the target distribution. We derive metrizable conditions, sufficient conditions for the discriminator to serve as the distance between the distributions, by connecting the GAN formulation with the concept of sliced optimal transport. Furthermore, by leveraging these theoretical results, we propose a novel GAN training scheme called the Slicing Adversarial Network (SAN). With only simple modifications, a broad class of existing GANs can be converted to SANs. Experiments on synthetic and image datasets support our theoretical results and the effectiveness of SAN as compared to the usual GANs. We also apply SAN to StyleGAN-XL, which leads to a state-of-the-art FID score amongst GANs for class conditional generation on CIFAR10 and ImageNet 256$times$256.

Citation

[1] Takida, Y., Imaizumi, M., Shibuya, T., Lai, C., Uesaka, T., Murata, N. and Mitsufuji, Y., "SAN: Inducing Metrizability of GAN with Discriminative Normalized Linear Layer," ICLR 2024.

@inproceedings{takida2024san,
    title={{SAN}: Inducing Metrizability of {GAN} with Discriminative Normalized Linear Layer},
    author={Takida, Yuhta and Imaizumi, Masaaki and Shibuya, Takashi and Lai, Chieh-Hsin and Uesaka, Toshimitsu and Murata, Naoki and Mitsufuji, Yuki},
    booktitle={The Twelfth International Conference on Learning Representations},
    year={2024},
    url={https://openreview.net/forum?id=eiF7TU1E8E}
}

san's People

Contributors

ak391 avatar takashishibuyasony avatar xl-sr avatar ytakida avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

anusarati

san's Issues

About out_fun, out_dir of simple-san

I have a question regarding the implementation of discriminator loss in the simple-san example.
According to Appendix B of the SAN paper, two discriminator outputs are defined: out_fun, where the direction vector is detached, and out_dir, where the intermediate feature is detached. Then out_fun is used for hinge loss, and out_dir is used for WGAN loss.

However, it appears that out_fun and out_dir are reversed in the current implementation of simple-san, as seen here:

out_fun = (h_feature.detach() * direction).sum(dim=1)
out_dir = (h_feature * direction.detach()).sum(dim=1)
out = dict(fun=out_fun, dir=out_dir)

Am I missing something, or is there an error in the implementation?

Experiments with MOG

Hello! Thank you for your paper and for the code. Have you published the code for experiments with Mixture of Gaussians? I can not find it in the repo. If it is published here, maybe you could put a link in the README file. Otherwise, please publish it!

About Train

May I ask if you could provide the training command? Thank you very much.

TypeError in loading pretrained pkl

Hello, Sir/Madam,

Thank you so much for sharing the code of the great work SAN. I like it very much.
I am trying to use the pretrained models. But when I run the following code
python calc_metrics.py --metrics=fid50k_full --network=./stylesan-xl_cifar10.pkl
I met the following error:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Loading network from "./sony_pretrained_models/stylesan-xl_cifar10.pkl"...
Traceback (most recent call last):
File "calc_metrics.py", line 191, in
calc_metrics() # pylint: disable=no-value-for-parameter
File "/home/shi/anaconda3/envs/san2/lib/python3.8/site-packages/click/core.py", line 1134, in call
return self.main(*args, **kwargs)
File "/home/shi/anaconda3/envs/san2/lib/python3.8/site-packages/click/core.py", line 1059, in main
rv = self.invoke(ctx)
File "/home/shi/anaconda3/envs/san2/lib/python3.8/site-packages/click/core.py", line 1401, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/shi/anaconda3/envs/san2/lib/python3.8/site-packages/click/core.py", line 767, in invoke
return __callback(*args, **kwargs)
File "/home/shi/anaconda3/envs/san2/lib/python3.8/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "calc_metrics.py", line 145, in calc_metrics
network_dict = legacy.load_network_pkl(f)
File "/data/shi/generation_fundamental/san-main/styleiisan-xl/legacy.py", line 25, in load_network_pkl
data = _LegacyUnpickler(f).load()
File "/home/shi/anaconda3/envs/san2/lib/python3.8/site-packages/dill/_dill.py", line 612, in _create_code
return CodeType(args[0], 0, 0, *args[1:])
TypeError: code() takes at most 16 arguments (19 given)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I have installed the exact environment as you proposed.
and I wonder from the error message, it seem the problem from 'dill' library, but I tried from version 0.3.3 to 0.3.8, But the error always exist. Can you help me with this error? Thank you in advance.

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.