-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: various fixes to keras interface + testing both keras and torch …
…interfaces with the frontend fixture
- Loading branch information
1 parent
7b6b7af
commit 0313bb2
Showing
9 changed files
with
228 additions
and
209 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import numpy as np | ||
from qibo import gates | ||
from qibo.models import QFT | ||
from qibo.quantum_info import random_clifford | ||
|
||
import qiboml.models.encoding_decoding as ed | ||
|
||
|
||
def test_probabilities_layer(backend): | ||
nqubits = 5 | ||
qubits = np.random.choice(range(nqubits), size=(4,), replace=False) | ||
layer = ed.ProbabilitiesLayer(nqubits, qubits=qubits, backend=backend) | ||
c = random_clifford(nqubits, backend=backend) | ||
backend.assert_allclose(layer(c).ravel(), c().probabilities(qubits)) | ||
|
||
|
||
def test_state_layer(backend): | ||
nqubits = 5 | ||
layer = ed.StateLayer(nqubits, backend=backend) | ||
c = random_clifford(nqubits, backend=backend) | ||
real, im = layer(c) | ||
backend.assert_allclose(real + 1j * im, c().state()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters