qml.gradients.generate_shifted_tapes

generate_shifted_tapes(tape, index, shifts, multipliers=None)[source]

Generate a list of tapes where one marked trainable parameter has been shifted by the provided shift values.

Parameters
  • tape (QuantumTape) – input quantum tape

  • index (int) – index of the trainable parameter to shift

  • shifts (Sequence[float or int]) – sequence of shift values. The length determines how many parameter-shifted tapes are created.

  • multipliers (Sequence[float or int]) – sequence of multiplier values. The length should match the one of shifts. Each multiplier scales the corresponding gate parameter before the shift is applied. If not provided, the parameters will not be scaled.

Returns

List of quantum tapes. In each tape the parameter indicated

by index has been shifted by the values in shifts. The number of tapes matches the lenth of shifts and multipliers (if provided).

Return type

list[QuantumTape]