qml.gradients.generate_shifted_tapes¶
- generate_shifted_tapes(tape, index, shifts, multipliers=None, broadcast=False)[source]¶
Generate a list of tapes or a single broadcasted tape, 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.broadcast (bool) – Whether or not to use broadcasting to create a single tape with the shifted parameters.
- Returns
- List of quantum tapes. In each tape the parameter indicated
by
index
has been shifted by the values inshifts
. The number of tapes matches the length ofshifts
andmultipliers
(if provided). Ifbroadcast=True
was used, the list contains a single broadcasted tape with all shifts distributed over the broadcasting dimension. In this case, thebatch_size
of the returned tape matches the length ofshifts
.
- Return type
list[QuantumTape]