-
Notifications
You must be signed in to change notification settings - Fork 188
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
Contextuality demo #719
Contextuality demo #719
Conversation
Thank you for opening this pull request. You can find the built site at this link. Deployment Info:
Note: It may take several minutes for updates to this pull request to be reflected on the deployed site. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice demo Joseph! That's a very clear example to work with 😄 Here I leave you a few comments. On the other hand, as the demo is called this way it would be nice if you could define a bit more in depth each of these concepts. A short paragraph to give the idea would be enough
|
||
###################################################################### | ||
# This demo is based on the article *Contextuality and inductive bias in | ||
# quantum machine learning* [1] by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't forget to put the links to the biography. Check another demo to see the format. It is usually in the form [#id_bio]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"by Joseph Bowles" 😆it is strange that you refer to yourself in the third person, but I imagine that is the correct way to put it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have changed the links. And haha I thought the same about the third person but I find it a bit weird to say 'be me'. I changed the language a bit in this paragraph to use 'we' rather than 'the authors' though.
and thanks for such a thorough review!!
# | ||
# - Describe a specific example of such a problem that is based on the | ||
# well known rock, paper scissors game, and | ||
# - Construct a train a quantum model that is tailored to the symmetries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# - Construct a train a quantum model that is tailored to the symmetries | |
# - Construct and train a quantum model that is tailored to the symmetries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have implemented all commit suggestions in the new version.
# `documentation <https://docs.pennylane.ai/en/stable/introduction/interfaces/jax.html>`__. | ||
# | ||
|
||
import jax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is better if you do not import the libraries in the introduction. As a general rule we usually import each library in the first cell that makes use of it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok done!
|
||
|
||
###################################################################### | ||
# This demo is based on the article *Contextuality and inductive bias in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would attract more attention if you reorder this paragraph. Let the first thing the user reads be the question. And then you can say that this is the question that motivates the article and we will work it into the demo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Have rewritten a bit.
# - If two players play different actions, then one player beats the | ||
# other following the usual rule (rock beats scissors, sissors beats | ||
# paper, paper beats rock). | ||
# - If two players play the same action, the one who plays their special |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reading this I'm not entirely sure I see how to play. Do all 3 players show a value at the same time? or do they go dueling 1 <> 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dueling. Have tried to make it clearer: I say 'The actions of the players are then compared pairwise with the following rules'
ax2.set_yscale("log") | ||
ax2.set_ylabel("Negative log likelihood (train)") | ||
ax2.set_xlabel("training step") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the output that appears is not intentional, to delete it I think it is enough to write plt.show() at the end of the cell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
# Incorporating knowledge about the data into the model design is | ||
# generally a very good idea! | ||
# | ||
# That is all for this demo. In the paper, it is also shown how models of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you include this paragraph under the heading conclusion?
In the conclusion, although it sounds a bit repetitive, we usually summarize quickly what we have seen in the demo. It is common to say at the end where to learn more. This is the perfect place to comment on what they will find in the paper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, have done that.
# | ||
# References | ||
# ---------- | ||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the format of the other demos to be able to link easily to the bio.
:property="og:description": Train a tailored quantum model on a contextuality-inspired dataset | ||
:property="og:image": https://pennylane.ai/qml/_images/contextuality_thumbnail.png | ||
|
||
*Author: Joseph Bowles — Posted: 21 March 2023* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you say that this demo is related to any other demo? Maybe the geometric machine learning demo? It is usually indicated here in the header. Take a look at the header
example:
.. related::
tutorial_quantum_chemistry Quantum chemistry with PennyLane
tutorial_vqe A brief overview of VQE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have added the GQML one
|
||
###################################################################### | ||
# The above game ia an example of a *zero-sum game*: if player 1 beats | ||
# player 2 then necessarily player 2 loses to player 1. This imples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# player 2 then necessarily player 2 loses to player 1. This imples | |
# player 2 then necessarily player 2 loses to player 1. This implies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some minor copy editing changes and suggestions. Everything else looks good to me. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @josephbowles , here are some minor copy editing changes and suggestions. Everything else looks good to me. :)
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
A problem has been detected with the jax version (it is not a problem of this demo). Next week it will be fixed :) |
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
Co-authored-by: Ivana Kurecic <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
(Guillermo is on holiday at the moment, but at least I can leave this as a lgtm from my end.)
… into contextuality_demo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Really cool topic!
Demo: Contextuality and inductive bias in quantum machine learning
This is a demo for my recent paper https://arxiv.org/abs/2302.01365
In the demo we study the toy learning problem described in the paper, and build and train a quantum model that encodes the relevant inductive bias. The model is shown to outperform a 'generic' quantum model that does not encode this bias.
The demo is not focused much on contextuality (because it would require a lot of explanation), but rather focuses on the type of learning problem (inspired from contextuality) that is presented in the paper.
JAX is used for vectorization and JIT compilation.