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

qGAN - Different behavior of numpy vs pytorch implementations of the discriminator #1

Closed
gabrieleagl opened this issue Oct 12, 2020 · 4 comments
Assignees
Labels
on hold 🛑 Can not fix yet

Comments

@gabrieleagl
Copy link
Contributor

Information

  • Qiskit Aqua version: 0.7.5
  • Python version: 3.8.5
  • Operating system: MacOS 10.15.7 (19H2)

What is the current behavior?

I'm running a script, based on the tutorial for distribution learning with qGAN's.
I have two variants of the script, grounded on the two different implementations of the qGAN discriminator, namely the NumPyDiscriminator and the PyTorchDiscriminator.
The two variants should provide the same results, as they both run the amsgrad optimizer, but I get significantly different worse results with NumPyDiscriminator. This suggests a bug in the NumPyDiscriminator implementation or in the ADAM class of qiskit.

Steps to reproduce the problem

I attach a simple script to run a single instance of the problem with either one or the other discriminator. Runtime is around 7-8min on my computer. testqGAN_bug.py.zip

To make the results more directly comparable, I made the following modifications to the standard qiskit classes:

  • Script _pytorch_discriminator_net.py, rows 57, 62, 66: replaced 512 with 50 and 256 with 20 to match the same architecture as in rows 52-56 of script numpy_discriminator.
  • Script numpy_discriminator, row 227: put noise factor to 0.
  • Script pytorch_discriminator, row 65: modified to self._optimizer = optim.Adam(self._discriminator.parameters(), lr=1e-3, betas = (.7, .99), eps=1e-6, amsgrad=True), to match parameters at row 226 of numpy_discriminator.
  • Script pytorch_discriminator, rows 234-235: commented to ignore gradient penalty.

What is the expected behavior?

The script provided in the attachment should give similar results both if run with qgan.set_discriminator(discriminator1) or qgan.set_discriminator(discriminator2) (small differences in different runs are possible, due to randomness in the algorithms).

Suggested solutions

None at the moment.

@gabrieleagl
Copy link
Contributor Author

@Zoufalc this is the issue, if you can give it a look!

@woodsp-ibm
Copy link
Member

Transferring to qiskit-machine-learning where the ML code from Aqua has been moved.

@woodsp-ibm woodsp-ibm transferred this issue from qiskit-community/qiskit-aqua Mar 3, 2021
@adekusar-drl
Copy link
Collaborator

The QGAN implementation is deprecated in #495. Unlikely this issue will be fixed.

@adekusar-drl adekusar-drl added the on hold 🛑 Can not fix yet label Oct 27, 2022
@adekusar-drl
Copy link
Collaborator

Closing this issue as the original QGAN implementation has been removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on hold 🛑 Can not fix yet
Projects
None yet
Development

No branches or pull requests

4 participants