mit-han-lab / torchquantum

A PyTorch-based framework for Quantum Classical Simulation, Quantum Machine Learning, Quantum Neural Networks, Parameterized Quantum Circuits with support for easy deployments on real quantum computers.
https://torchquantum.org
MIT License
1.24k stars 184 forks source link

QGAN.Py #270

Closed AbdullahKazi500 closed 3 weeks ago

AbdullahKazi500 commented 1 month ago

define a Generator class, which generates quantum states from latent vectors. define a Discriminator class, which distinguishes between real and fake quantum states. The QGAN class combines the generator and discriminator to form the QGAN model. The forward method of the QGAN class generates fake quantum states using the generator and then passes them through the discriminator to obtain the discriminator's output fixes #264

GenericP3rson commented 4 weeks ago

Hello, thanks for your patience!

To be more specific for the examples, if you could create a new folder in the examples folder, add a README, parametrize your python file, and add a python notebook, that would complete the task. For more details, check out the other PR linked to the issue.

Let me know if you have any questions!

AbdullahKazi500 commented 4 weeks ago

created PR to address the issue @GenericP3rson

276

AbdullahKazi500 commented 4 weeks ago

@GenericP3rson in the pull request #276 I have created a parametrized script and in the recent commit on the PR I have made a notebook which can be seen above

AbdullahKazi500 commented 3 weeks ago

If you could combine the updated into one PR, that would be most ideal. You should be able to add a folder to examples by cloning the repository and editing it.

Then you will want to parametrize the example with command line arguments (use argparse instead of system arguments). If you add an algorithm, the example should import it (which is why you should add it to the same PR).

To reiterate a bit more clearly, changes needed are:

  1. Clone the repository and add a new folder. (You will also want to create a README in this folder)
  2. Algorithms are meant to be imported. So you will want to import your algorithm to your example, so you will need to combine the two PRs.
  3. Use argparse to pass command-line arguments to your script

Hi @GenericP3rson updated the code in the same PR Combined both the script and the notebook into one PR Used argparse added a new folder added a readme with description

implemented and trained a QGAN on the CIFAR-10 dataset to generate fake images. It follows a similar structure to the TorchQuantum QGAN, with the addition of data loading and processing specific to the CIFAR-10 dataset.

Task Completion Generator Output Specification-The generator class is defined to generate fake quantum data samples. we get the generated images

Loss Function Definition- In the QGAN implementation, the loss function is defined during the training loop. The adversarial training process involves simultaneously optimizing both the generator and discriminator networks using their respective loss functions.

added the generated images in the same folder @GenericP3rson

QGANPng2 QGANPng

rakeshy32 commented 3 weeks ago

I appreciate the effort you've put into implementing this complex model. I was curious how well this implementation of QGAN can work. I have two comments:

I understand that these are complex issues, and I'm happy to help you work through them. If you have any questions or need further clarification, please don't hesitate to ask.

GenericP3rson commented 3 weeks ago

@AbdullahKazi500 Can you also address @rakeshy32’s comments? We’re happy to merge this, but it would be great if you could work with @rakeshy32 to update the example!

AbdullahKazi500 commented 3 weeks ago

@AbdullahKazi500 Can you also address @rakeshy32’s comments? We’re happy to merge this, but it would be great if you could work with @rakeshy32 to update the example!

Hi I have already addressed Rakesh's comment in the PR

AbdullahKazi500 commented 3 weeks ago

Task Completion Generator Output Specification-The generator class is defined to generate fake quantum data samples. we get the generated images

Loss Function Definition- In the QGAN implementation, the loss function is defined during the training loop. The adversarial training process involves simultaneously optimizing both the generator and discriminator networks using their respective loss functions.

@GenericP3rson I have already addressed this in the PR but still I can look into it with Rakesh Hi Rakesh Task Completion Generator Output Specification-The generator class is defined to generate fake quantum data samples. we get the generated images

Loss Function Definition- In the QGAN implementation, the loss function is defined during the training loop. The adversarial training process involves simultaneously optimizing both the generator and discriminator networks using their respective loss functions.

QGANPng2 QGANPng

rakeshy32 commented 3 weeks ago

Thank you for your effort in addressing the issues. However, I did notice that the implementation in the notebook "QGANtorch (2).ipynb" does not include any quantum layers. Instead, it appears to be a fully classical model. Additionally, the generated images from this classical model appear to be nothing but noise. I think the demo should be on training a QGAN and then generating images.

Overall, I appreciate your contribution and the effort you put into development of QGAN. I hope these suggestions are helpful.

AbdullahKazi500 commented 3 weeks ago

Thank you for your effort in addressing the issues. However, I did notice that the implementation in the notebook "QGANtorch (2).ipynb" does not include any quantum layers. Instead, it appears to be a fully classical model. Additionally, the generated images from this classical model appear to be nothing but noise. I think the demo should be on training a QGAN and then generating images.

Overall, I appreciate your contribution and the effort you put into development of QGAN. I hope these suggestions are helpful.

Okay Thanks Rakesh