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

Add Keras layers support #529

Merged
merged 84 commits into from Apr 1, 2020
Merged

Add Keras layers support #529

merged 84 commits into from Apr 1, 2020

Conversation

trbromley
Copy link
Contributor

@trbromley trbromley commented Mar 2, 2020

This PR provides a KerasLayer class for converting a PennyLane QNode to a Keras layer, which can then be used within standard Keras features such as the Model/Sequential models.

Currently, the following is not added:

  • A tutorial/demo to show how to use this new feature
  • A section in "Using PennyLane" of the documentation showing a higher level picture. This and the above could be added together.
  • Supporting input of a QNodeCollection instead of a single QNode. This should be possible, we need to make the func.sig attribute available in the QNodeCollection and in qml.map.

Providing this functionality would help solve #166 and is also discussed in #133, https://discuss.pennylane.ai/t/qnode-inside-keras-layer/335/3 and https://discuss.pennylane.ai/t/creating-and-saving-models/46.

@trbromley trbromley added the WIP 🚧 Work-in-progress label Mar 2, 2020
@trbromley trbromley requested a review from josh146 March 2, 2020 21:45
@trbromley trbromley self-assigned this Mar 2, 2020
@codecov
Copy link

codecov bot commented Mar 2, 2020

Codecov Report

Merging #529 into master will not change coverage by %.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #529   +/-   ##
=======================================
  Coverage   98.89%   98.89%           
=======================================
  Files          82       82           
  Lines        5075     5075           
=======================================
  Hits         5019     5019           
  Misses         56       56           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 861ec80...861ec80. Read the comment docs.

tests/test_qnn.py Outdated Show resolved Hide resolved
Copy link
Contributor Author

@trbromley trbromley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @josh146! Should have answered your questions.

pennylane/qnn/keras.py Show resolved Hide resolved
pennylane/qnn/keras.py Outdated Show resolved Hide resolved
pennylane/qnn/keras.py Outdated Show resolved Hide resolved
test.py Outdated Show resolved Hide resolved
tests/qnn/test_keras.py Show resolved Hide resolved
@trbromley trbromley requested a review from josh146 March 31, 2020 19:21
pennylane/qnn/keras.py Outdated Show resolved Hide resolved
Copy link
Member

@josh146 josh146 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

pennylane/qnn/keras.py Show resolved Hide resolved
@trbromley trbromley merged commit 40d480d into master Apr 1, 2020
@trbromley trbromley deleted the keras_layer branch April 1, 2020 13:46
@co9olguy
Copy link
Member

co9olguy commented Apr 1, 2020

🎆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request review-ready 👌 PRs which are ready for review by someone from the core team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants