-
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.
- Loading branch information
1 parent
0e8656b
commit 2c79d18
Showing
4 changed files
with
118 additions
and
34 deletions.
There are no files selected for viewing
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,86 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "f929e9a9-d6c3-4857-b9b5-bc4f267955f0", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"BinaryEncodingLayer(nqubits=3, qubits=range(0, 3), circuit=<qibo.models.circuit.Circuit object at 0x795ab0567f40>, initial_state=None, backend=tensorflow)\n", | ||
"ReuploadingLayer(nqubits=3, qubits=range(0, 3), circuit=<qibo.models.circuit.Circuit object at 0x795a052328f0>, initial_state=None, backend=tensorflow)\n", | ||
"QuantumDecodingLayer(nqubits=3, qubits=range(0, 3), circuit=<qibo.models.circuit.Circuit object at 0x795a052335e0>, initial_state=None, backend=tensorflow, nshots=1000)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from qiboml.models.encoding_decoding import *\n", | ||
"from qiboml.models.ansatze import *\n", | ||
"\n", | ||
"model = [BinaryEncodingLayer(nqubits=3), ReuploadingLayer(nqubits=3), QuantumDecodingLayer(nqubits=3)]\n", | ||
"for m in model:\n", | ||
" print(m)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "09cccd24-dece-4279-bcd2-7006582458c2", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[<tf.Tensor: shape=(8,), dtype=float64, numpy=array([1., 0., 0., 0., 0., 0., 0., 0.])>, <tf.Tensor: shape=(8,), dtype=float64, numpy=array([0., 0., 1., 0., 0., 0., 0., 0.])>, <tf.Tensor: shape=(8,), dtype=float64, numpy=array([0., 0., 0., 0., 1., 0., 0., 0.])>]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import numpy as np\n", | ||
"\n", | ||
"data = np.array([[0,0,0], [0,1,0], [1,1,0]])\n", | ||
"result = []\n", | ||
"\n", | ||
"for d in data:\n", | ||
" x = model[0].forward(d)\n", | ||
" x = model[1].forward(x)\n", | ||
" result.append(model[2].forward(x).probabilities())\n", | ||
"\n", | ||
"print(result)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "005b4456-baab-486d-901a-0834ee042f54", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.14" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |