tn_noise_learning.dataset#
Shot-level noise-learning dataset stored as a zarr group.
Layout of dataset.zarr::
attrs format_version, num_qubits, created, circuit_qasm2 (optional)
inputs int8 (num_shots, num_qubits) label of the prepared state on each qubit, index into states[j]
outcomes int8 (num_shots, num_qubits) label of the measured effect on each qubit, index into povms[j]
states complex128 (num_qubits, num_states, 2, 2)
povms complex128 (num_qubits, num_effects, 2, 2)
ideal_channel/ optional LPDO group (see LPDO.to_group) used only to report the distance during training
Batch #
Bases: NamedTuple
One training batch: per-site state and effect matrices, each of shape (num_qubits, batch, 2, 2).
NoiseDataset
dataclass
#
NoiseDataset(
inputs: ndarray,
outcomes: ndarray,
states: ndarray,
povms: ndarray,
circuit: QuantumCircuit | None = None,
ideal_channel: LPDO | None = None,
)
Shots of a process-tomography experiment on product states with product measurements.
| PARAMETER | DESCRIPTION |
|---|---|
inputs
|
prepared-state labels, shape
TYPE:
|
outcomes
|
measured-effect labels, shape
TYPE:
|
states
|
single-qubit input states per qubit, shape
TYPE:
|
povms
|
single-qubit effects per qubit, shape
TYPE:
|
circuit
|
ideal circuit applied before the noise channel, or
TYPE:
|
ideal_channel
|
ground-truth channel, if known, to report the distance to during training.
TYPE:
|
__len__ #
__len__() -> int
Number of recorded shots.
Source code in src/tn_noise_learning/dataset.py
110 111 112 | |
__post_init__ #
__post_init__() -> None
Normalise dtypes and validate shapes and label ranges.
Source code in src/tn_noise_learning/dataset.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
batches #
batches(
batch_size: int,
*,
shuffle: bool = True,
seed: int = 0,
drop_last: bool = True,
) -> Iterator[Batch]
Iterate over batches; with drop_last every batch has exactly batch_size shots (one JIT trace).
Source code in src/tn_noise_learning/dataset.py
131 132 133 134 135 136 137 138 139 140 | |
gather #
gather(indices: ndarray) -> Batch
State and effect matrices of the given shots, shape (num_qubits, len(indices), 2, 2) each.
Source code in src/tn_noise_learning/dataset.py
126 127 128 129 | |
load
classmethod
#
load(path: str | Path) -> NoiseDataset
Read a dataset written by save.
Source code in src/tn_noise_learning/dataset.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
save #
save(path: str | Path) -> None
Write the dataset to a zarr store at path (overwriting).
Source code in src/tn_noise_learning/dataset.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
split #
split(
test_fraction: float = 0.1, seed: int = 0
) -> tuple[NoiseDataset, NoiseDataset]
Random disjoint (train, test) split.
Source code in src/tn_noise_learning/dataset.py
118 119 120 121 122 123 124 | |
subset #
subset(indices: ndarray) -> NoiseDataset
Dataset restricted to the given shots; states, povms, circuit and ideal channel are shared.
Source code in src/tn_noise_learning/dataset.py
114 115 116 | |