pdft.loss.loss_function

Contents

pdft.loss.loss_function#

pdft.loss.loss_function(tensors, m, n, code, pic, loss, *, inverse_code=None)[source]#

Compute scalar loss for a single image under the given circuit.

Mirror of upstream src/loss.jl:94-104. See Spec Section 4.

Parameters:
  • tensors (list[Array]) – Current circuit parameters (unitary matrices, possibly phases).

  • m (int) – Qubit counts; pic must be (2**m, 2**n).

  • n (int) – Qubit counts; pic must be (2**m, 2**n).

  • code (callable) – Forward einsum closure (from qft_code or equivalent).

  • pic (Array) – Input image, shape (2**m, 2**n).

  • loss (AbstractLoss) – L1Norm or MSELoss instance.

  • inverse_code (callable, optional) – Required for MSELoss; the inverse einsum closure.

Return type:

Array