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
indexhas been shifted by the values inshifts. The number of tapes matches the length ofshiftsandmultipliers(if provided). Ifbroadcast=Truewas used, the list contains a single broadcasted tape with all shifts distributed over the broadcasting dimension. In this case, thebatch_sizeof the returned tape matches the length ofshifts.
- Return type:
list[QuantumTape]