Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for DSGAN example #494

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

Koukyosyumei
Copy link

@Koukyosyumei Koukyosyumei commented Sep 3, 2022

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Motivation and Context / Related issue

I would like to solve #418. I quickly implemented two solutions suggested in the forum. Though I have created two separate py scripts for the solutions, I will experiment with the model performance of each solution and merge the better one. Since this is the first PR for opacus, any suggestions and help are welcome!

How Has This Been Tested (if it applies)

1. Loss (and accuracy)

The losses of the original implementation, solution 1, and solution 2 correspond to green, yellow, and blur lines. Due to the memory limitation, solution 2 works only batch size = 32for my environment (google colab).

batchsize_32
batchsize_64

2. Examples of generated images

batch size 64

  • original implementation

fake_samples_epoch_022

  • solution 1

fake_samples_epoch_021

batch size 32

  • original implementation

fake_samples_epoch_024 (1)

  • solution 1

fake_samples_epoch_021 (1)

  • solution 2

fake_samples_epoch_020

3. Final $\epsilon$

batch size 64

$\epsilon$
original 4.82
solution 1 3.36

Checklist

  • The documentation is up-to-date with the changes I made.
  • I have read the CONTRIBUTING document and completed the CLA (see CONTRIBUTING).
  • All tests passed, and additional code has been covered with new tests.

@facebook-github-bot
Copy link
Contributor

Hi @Koukyosyumei!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@Koukyosyumei Koukyosyumei marked this pull request as draft September 3, 2022 13:20
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 3, 2022
@Koukyosyumei
Copy link
Author

Koukyosyumei commented Sep 5, 2022

I have run both scripts and found that only patch_1 (clipping gradients for both fake and real data) works. I think it is reasonable that the second approach, which uses two optimizers, makes the gradients for actual data too small compared to real data due to the gradient clipping. I also tried applying clip_grad_norm, but it did not work at least for the current parameters. Also, the second approach has to consume more memory than the first one. Thus, I suggest using the first solution.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@Koukyosyumei has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@Koukyosyumei Koukyosyumei marked this pull request as ready for review September 6, 2022 07:33
@Koukyosyumei Koukyosyumei changed the title [WIP] Patch dcgan Patch dcgan Sep 6, 2022
@Koukyosyumei Koukyosyumei changed the title Patch dcgan Patch for DSGAN example Sep 6, 2022
@romovpa
Copy link
Contributor

romovpa commented Sep 6, 2022

@Koukyosyumei Thank you very much for working on this!
May I ask you to provide some quantified results for the run that can show that the new version works correctly? You can put them in the testing section of this PR.

@facebook-github-bot
Copy link
Contributor

@Koukyosyumei has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@Koukyosyumei
Copy link
Author

Koukyosyumei commented Sep 9, 2022

@romovpa

I am sorry for the late reply. As suggested in the test section, solution 1 gives better loss, synthesized images, and $\epsilon$ than others. I also notice that #474 has already tackled this issue. If this PR is not necessary, please close it.

@facebook-github-bot
Copy link
Contributor

@Koukyosyumei has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@Koukyosyumei has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@Koukyosyumei has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@ffuuugor ffuuugor self-requested a review October 21, 2022 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants