qp.labs.tcdq.MMDConfig¶
- class MMDConfig(bandwidth=None, n_ops=None, wires=None, sqrt_loss=False, return_per_bandwidth=False, bootstrap_target_data=True)[source]¶
Bases:
objectHyperparameters for the qubit Maximum Mean Discrepancy (MMD) loss.
The MMD measures how well the model’s output distribution matches a target dataset.
- Parameters:
bandwidth (float | Sequence[float]) – The bandwidth \(\sigma^2\) of the kernel. If a sequence is provided, the loss is evaluated for each value and then averaged, unless
return_per_bandwidth=True.n_ops (int) – Number of sampled observables per bandwidth. Larger values reduce estimator variance.
wires (Sequence[int] | None) – Subset of qubit indices to include in the loss. If
None(default), all qubits are used.sqrt_loss (bool) – If
True, return \(\sqrt{|\text{MMD}^2|}\) instead of \(\text{MMD}^2\). Defaults toFalse.return_per_bandwidth (bool) – If
True, return a list of per-bandwidth loss values instead of their scalar average. Defaults toFalse.bootstrap_target_data (bool) – If
True, resampletarget_datawith replacement before computing the loss. This makes the target-target U-statistic unbiased with respect to the empirical target distribution. Defaults toTrue.
Example
>>> from pennylane.labs.tcdq import MMDConfig, median_heuristic >>> import numpy as np >>> target_data = np.random.binomial(1, 0.5, size=(200, 6)) >>> bw = median_heuristic(target_data) >>> config = MMDConfig(bandwidth=bw, n_ops=64)
Attributes
Width of the RBF kernel (scalar or sequence for multi-bandwidth).
If
True, bootstrap the target data before computing the loss.Number of sampled observables per bandwidth.
If
True, return per-bandwidth losses instead of their average.If
True, returnsqrt(|MMD²|)instead ofMMD².Subset of qubit indices to include, or
Nonefor all qubits.- bandwidth = None¶
Width of the RBF kernel (scalar or sequence for multi-bandwidth).
- bootstrap_target_data = True¶
If
True, bootstrap the target data before computing the loss.
- n_ops = None¶
Number of sampled observables per bandwidth.
- return_per_bandwidth = False¶
If
True, return per-bandwidth losses instead of their average.
- sqrt_loss = False¶
If
True, returnsqrt(|MMD²|)instead ofMMD².
- wires = None¶
Subset of qubit indices to include, or
Nonefor all qubits.