Skip to content

Commit

Permalink
adapted encoding strategy
Browse files Browse the repository at this point in the history
Signed-off-by: Melvin Strobl <[email protected]>
  • Loading branch information
Melvin Strobl committed Jan 13, 2025
1 parent 31f36b5 commit fcc7eb4
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions qml_essentials/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,17 +337,29 @@ def _iec(
if data_reupload:
if inputs.shape[1] == 1:
for q in range(self.n_qubits):
enc(inputs[:, 0], wires=q, noise_params=noise_params)
if noise_params is not None:
enc(inputs[:, 0], wires=q, noise_params=noise_params)
else:
enc(inputs[:, 0], wires=q)
else:
for q in range(self.n_qubits):
for idx in range(inputs.shape[1]):
enc[idx](inputs[:, idx], wires=q, noise_params=noise_params)
if noise_params is not None:
enc[idx](inputs[:, idx], wires=q, noise_params=noise_params)
else:
enc[idx](inputs[:, idx], wires=q)
else:
if inputs.shape[1] == 1:
enc(inputs[:, 0], wires=0, noise_params=noise_params)
if noise_params is not None:
enc(inputs[:, 0], wires=0, noise_params=noise_params)
else:
enc(inputs[:, 0], wires=0)
else:
for idx in range(inputs.shape[1]):
enc[idx](inputs[:, idx], wires=0, noise_params=noise_params)
if noise_params is not None:
enc[idx](inputs[:, idx], wires=0, noise_params=noise_params)
else:
enc[idx](inputs[:, idx], wires=0)

def _circuit(
self,
Expand Down

0 comments on commit fcc7eb4

Please sign in to comment.