Skip to content

Commit

Permalink
Differentiable parameter-shift gradient transform (#1479)
Browse files Browse the repository at this point in the history
* more

* more

* more

* more

* more

* add tests

* more tests

* more tests

* changelog

* add todo

* fix

* fix

* fix

* Apply suggestions from code review

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* add parameter-shift

* add parameter-shift

* changes

* fixes

* fixes

* suggested changes

* linting

* add tests

* add tests

* bug

* remove stack

* Apply suggestions from code review

Co-authored-by: Maria Schuld <mariaschuld@gmail.com>

* Update pennylane/gradients/finite_difference.py

* more

* suggested changes

* suggested changes

* typo

* Apply suggestions from code review

Co-authored-by: antalszava <antalszava@gmail.com>

* suggested changes

* Update pennylane/gradients/parameter_shift.py

Co-authored-by: antalszava <antalszava@gmail.com>

* suggested changes

* Apply suggestions from code review

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/gradients/parameter_shift.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* suggested changes

* suggested changes

* suggested changes

* suggested changes

* suggested changes

* suggested changes

* suggested changes

* suggested changes

* Apply suggestions from code review

Co-authored-by: Maria Schuld <mariaschuld@gmail.com>

* added multiplier test

* Suggested changes

* suggested changes

* suggested changes

* typo

* Apply suggestions from code review

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* suggested changes

* Update tests/gradients/test_parameter_shift.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: Maria Schuld <mariaschuld@gmail.com>
  • Loading branch information
4 people committed Aug 3, 2021
1 parent f2bb1a0 commit ab71001
Show file tree
Hide file tree
Showing 4 changed files with 1,437 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pennylane/gradients/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
import pennylane as qml

from . import finite_difference
from . import parameter_shift

from .finite_difference import finite_diff, finite_diff_coeffs, generate_shifted_tapes
from .parameter_shift import param_shift
3 changes: 3 additions & 0 deletions pennylane/gradients/finite_difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
of a quantum tape.
"""
# pylint: disable=protected-access,too-many-arguments
import functools

import numpy as np
from scipy.special import factorial

import pennylane as qml


@functools.lru_cache(maxsize=None)
def finite_diff_coeffs(n, approx_order, strategy):
r"""Generate the finite difference shift values and corresponding
term coefficients for a given derivative order, approximation accuracy,
Expand Down
Loading

0 comments on commit ab71001

Please sign in to comment.