In [26]:
!pip install tqdm
Requirement already satisfied: tqdm in /home/lpawela/miniconda3/envs/parrondo-old/lib/python3.12/site-packages (4.67.1)
In [27]:
import numpy as np
from qiskit_aer import AerSimulator
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, transpile
from qiskit.visualization import plot_histogram
from itertools import product
from tqdm import tqdm
Definition of the sign flip¶
$$\operatorname{SF}_{N,j} = O_j (C^NZ) O_j$$
$$O_j = \otimes_{l=0}^{N-1} (\operatorname{NOT}_l)^{1-j_l}$$
Choose $N$ and $j$. $j$ represents the elements of the computational basis.
In [28]:
def num2bin(num, n):
return np.array([int(i) for i in np.binary_repr(num, n)])
def O(q, j):
O_circ = QuantumCircuit(q, name=f"O_{''.join([str(i) for i in j])}")
for (i, v) in enumerate(j):
if v == 0:
O_circ.x(q[i])
O_circ.barrier()
return O_circ
def sf(q, j):
N = q.size
SF = QuantumCircuit(q, name=f"SF_{q.size}_{''.join([str(i) for i in j])}")
SF.append(O(q, j), q)
SF.barrier(q)
# SF.mcrz(np.pi, q[:N-1], q[N-1])
SF.mcp(np.pi, q[:N-1], q[N-1])
SF.barrier(q)
SF.append(O(q, j), q)
return SF
In [29]:
def U_i(q, input_vector):
u_i = QuantumCircuit(q, name=f"U^i_{''.join([str(i) for i in input_vector])}")
N = q.size
u_i.h(q)
for (i, v) in enumerate(input_vector):
if v:
bin_num = num2bin(i, N)
u_i.append(sf(q, bin_num), q)
u_i.barrier()
return u_i
In [30]:
def U_w(q, weight_vector):
u_w = QuantumCircuit(q, name=f"U^w_{''.join([str(i) for i in weight_vector])}")
N = q.size
for (i, v) in enumerate(weight_vector):
if v:
bin_num = num2bin(i, N)
u_w.append(sf(q, bin_num), q)
u_w.barrier()
u_w.h(q)
u_w.x(q)
return u_w
In [31]:
N = 2
q = QuantumRegister(N, 'q')
input_vector = [0, 0, 0, 0]
circ = QuantumCircuit(q)
circ.append(U_i(q, input_vector), q)
circ.decompose(reps=1).draw(output='mpl')
Out[31]:
In [33]:
N = 2
q = QuantumRegister(N, 'q')
a = QuantumRegister(1, 'a')
b = ClassicalRegister(1, 'b')
circ = QuantumCircuit(q, a, b)
circ.append(U_i(q, num2bin(0, N)[::-1]), q)
circ.append(U_w(q, num2bin(3, N)), q)
circ.mcrx(np.pi, q, a[0])
circ.measure(a, b)
circ.decompose(reps=0).draw(output='mpl')
Out[33]:
In [34]:
simulator = AerSimulator()
job = simulator.run(transpile(circ, simulator), shots=1024)
result = job.result()
counts = result.get_counts(circ)
print("\nTotal counts are:",counts)
plot_histogram(counts)
Total counts are: {'0': 1024}
Out[34]:
Input vs weights matrix¶
Below we compare all the input vectors against all the weight vectors, for a specified $N$. We're computing a square matrix with a side of $2^{2^N}$ elements.
Start with $N=2$ to see results within your lifetime.
The results are saved in outcomes, and can be viewed in an image in the cell below.
In [35]:
N = 2
shots = 1024
outcomes = np.zeros((2**(2**N),2**(2**N)))
for (i, w) in tqdm(product(range(2**(2**N)), repeat=2)):
q = QuantumRegister(N, 'q')
a = QuantumRegister(1, 'a')
b = ClassicalRegister(1, 'b')
circ = QuantumCircuit(q, a, b)
x = num2bin(i, 2**N)
ww = num2bin(w, 2**N)
circ.append(U_i(q, x), q)
circ.append(U_w(q, ww), q)
circ.mcrx(np.pi, q, a[0])
circ.measure(a, b)
simulator = AerSimulator()
job = simulator.run(transpile(circ, simulator), shots=shots)
result = job.result()
counts = result.get_counts(circ)
outcomes[i][w] = counts.get('1', 0) / shots
print(i,x, w, ww, counts)
3it [00:00, 21.44it/s]
0 [0 0 0 0] 0 [0 0 0 0] {'1': 1024}
0 [0 0 0 0] 1 [0 0 0 1] {'1': 263, '0': 761}
0 [0 0 0 0] 2 [0 0 1 0] {'1': 253, '0': 771}
0 [0 0 0 0] 3 [0 0 1 1] {'0': 1024}
0 [0 0 0 0] 4 [0 1 0 0] {'0': 764, '1': 260}
6it [00:00, 20.22it/s]
0 [0 0 0 0] 5 [0 1 0 1] {'0': 1024}
0 [0 0 0 0] 6 [0 1 1 0] {'0': 1024}
0 [0 0 0 0] 7 [0 1 1 1] {'1': 232, '0': 792}
9it [00:00, 19.03it/s]
0 [0 0 0 0] 8 [1 0 0 0] {'1': 253, '0': 771}
11it [00:00, 18.93it/s]
0 [0 0 0 0] 9 [1 0 0 1] {'0': 1024}
0 [0 0 0 0] 10 [1 0 1 0] {'0': 1024}
0 [0 0 0 0] 11 [1 0 1 1] {'1': 248, '0': 776}
13it [00:00, 18.83it/s]
0 [0 0 0 0] 12 [1 1 0 0] {'0': 1024}
0 [0 0 0 0] 13 [1 1 0 1] {'1': 235, '0': 789}
16it [00:00, 19.63it/s]
0 [0 0 0 0] 14 [1 1 1 0] {'1': 245, '0': 779}
0 [0 0 0 0] 15 [1 1 1 1] {'1': 1024}
18it [00:00, 19.38it/s]
1 [0 0 0 1] 0 [0 0 0 0] {'1': 264, '0': 760}
1 [0 0 0 1] 1 [0 0 0 1] {'1': 1024}
20it [00:01, 19.48it/s]
1 [0 0 0 1] 2 [0 0 1 0] {'0': 1024}
1 [0 0 0 1] 3 [0 0 1 1] {'1': 250, '0': 774}
1 [0 0 0 1] 4 [0 1 0 0] {'0': 1024}
23it [00:01, 20.57it/s]
1 [0 0 0 1] 5 [0 1 0 1] {'1': 255, '0': 769}
1 [0 0 0 1] 6 [0 1 1 0] {'1': 231, '0': 793}
26it [00:01, 20.36it/s]
1 [0 0 0 1] 7 [0 1 1 1] {'0': 1024}
1 [0 0 0 1] 8 [1 0 0 0] {'0': 1024}
1 [0 0 0 1] 9 [1 0 0 1] {'1': 267, '0': 757}
1 [0 0 0 1] 10 [1 0 1 0] {'1': 271, '0': 753}
1 [0 0 0 1] 11 [1 0 1 1] {'0': 1024}
29it [00:01, 20.22it/s]
1 [0 0 0 1] 12 [1 1 0 0] {'1': 264, '0': 760}
1 [0 0 0 1] 13 [1 1 0 1] {'0': 1024}
32it [00:01, 19.19it/s]
1 [0 0 0 1] 14 [1 1 1 0] {'1': 1024}
1 [0 0 0 1] 15 [1 1 1 1] {'0': 766, '1': 258}
2 [0 0 1 0] 0 [0 0 0 0] {'0': 761, '1': 263}
2 [0 0 1 0] 1 [0 0 0 1] {'0': 1024}
35it [00:01, 19.39it/s]
2 [0 0 1 0] 2 [0 0 1 0] {'1': 1024}
2 [0 0 1 0] 3 [0 0 1 1] {'1': 249, '0': 775}
2 [0 0 1 0] 4 [0 1 0 0] {'0': 1024}
38it [00:01, 19.85it/s]
2 [0 0 1 0] 5 [0 1 0 1] {'1': 242, '0': 782}
2 [0 0 1 0] 6 [0 1 1 0] {'1': 256, '0': 768}
40it [00:02, 19.81it/s]
2 [0 0 1 0] 7 [0 1 1 1] {'0': 1024}
2 [0 0 1 0] 8 [1 0 0 0] {'0': 1024}
42it [00:02, 18.55it/s]
2 [0 0 1 0] 9 [1 0 0 1] {'1': 274, '0': 750}
2 [0 0 1 0] 10 [1 0 1 0] {'0': 754, '1': 270}
44it [00:02, 18.01it/s]
2 [0 0 1 0] 11 [1 0 1 1] {'0': 1024}
2 [0 0 1 0] 12 [1 1 0 0] {'1': 257, '0': 767}
46it [00:02, 18.22it/s]
2 [0 0 1 0] 13 [1 1 0 1] {'1': 1024}
48it [00:02, 15.97it/s]
2 [0 0 1 0] 14 [1 1 1 0] {'0': 1024}
2 [0 0 1 0] 15 [1 1 1 1] {'1': 255, '0': 769}
51it [00:02, 17.73it/s]
3 [0 0 1 1] 0 [0 0 0 0] {'0': 1024}
3 [0 0 1 1] 1 [0 0 0 1] {'1': 245, '0': 779}
3 [0 0 1 1] 2 [0 0 1 0] {'1': 248, '0': 776}
53it [00:02, 18.11it/s]
3 [0 0 1 1] 3 [0 0 1 1] {'1': 1024}
3 [0 0 1 1] 4 [0 1 0 0] {'1': 274, '0': 750}
56it [00:02, 18.86it/s]
3 [0 0 1 1] 5 [0 1 0 1] {'0': 1024}
3 [0 0 1 1] 6 [0 1 1 0] {'0': 1024}
3 [0 0 1 1] 7 [0 1 1 1] {'0': 780, '1': 244}
58it [00:03, 18.91it/s]
3 [0 0 1 1] 8 [1 0 0 0] {'1': 271, '0': 753}
3 [0 0 1 1] 9 [1 0 0 1] {'0': 1024}
60it [00:03, 18.48it/s]
3 [0 0 1 1] 10 [1 0 1 0] {'0': 1024}
3 [0 0 1 1] 11 [1 0 1 1] {'1': 252, '0': 772}
62it [00:03, 18.30it/s]
3 [0 0 1 1] 12 [1 1 0 0] {'1': 1024}
3 [0 0 1 1] 13 [1 1 0 1] {'1': 252, '0': 772}
64it [00:03, 18.71it/s]
3 [0 0 1 1] 14 [1 1 1 0] {'1': 238, '0': 786}
3 [0 0 1 1] 15 [1 1 1 1] {'0': 1024}
4 [0 1 0 0] 0 [0 0 0 0] {'1': 268, '0': 756}
67it [00:03, 19.35it/s]
4 [0 1 0 0] 1 [0 0 0 1] {'0': 1024}
4 [0 1 0 0] 2 [0 0 1 0] {'0': 1024}
69it [00:03, 19.46it/s]
4 [0 1 0 0] 3 [0 0 1 1] {'0': 765, '1': 259}
4 [0 1 0 0] 4 [0 1 0 0] {'1': 1024}
4 [0 1 0 0] 5 [0 1 0 1] {'1': 234, '0': 790}
72it [00:03, 19.95it/s]
4 [0 1 0 0] 6 [0 1 1 0] {'1': 267, '0': 757}
4 [0 1 0 0] 7 [0 1 1 1] {'0': 1024}
75it [00:03, 20.33it/s]
4 [0 1 0 0] 8 [1 0 0 0] {'0': 1024}
4 [0 1 0 0] 9 [1 0 0 1] {'1': 265, '0': 759}
4 [0 1 0 0] 10 [1 0 1 0] {'1': 254, '0': 770}
4 [0 1 0 0] 11 [1 0 1 1] {'1': 1024}
4 [0 1 0 0] 12 [1 1 0 0] {'1': 248, '0': 776}
78it [00:04, 20.14it/s]
4 [0 1 0 0] 13 [1 1 0 1] {'0': 1024}
4 [0 1 0 0] 14 [1 1 1 0] {'0': 1024}
4 [0 1 0 0] 15 [1 1 1 1] {'1': 258, '0': 766}
81it [00:04, 20.23it/s]
5 [0 1 0 1] 0 [0 0 0 0] {'0': 1024}
5 [0 1 0 1] 1 [0 0 0 1] {'1': 234, '0': 790}
84it [00:04, 19.55it/s]
5 [0 1 0 1] 2 [0 0 1 0] {'1': 263, '0': 761}
5 [0 1 0 1] 3 [0 0 1 1] {'0': 1024}
86it [00:04, 18.50it/s]
5 [0 1 0 1] 4 [0 1 0 0] {'1': 234, '0': 790}
5 [0 1 0 1] 5 [0 1 0 1] {'1': 1024}
5 [0 1 0 1] 6 [0 1 1 0] {'0': 1024}
5 [0 1 0 1] 7 [0 1 1 1] {'1': 274, '0': 750}
89it [00:04, 18.48it/s]
5 [0 1 0 1] 8 [1 0 0 0] {'1': 258, '0': 766}
5 [0 1 0 1] 9 [1 0 0 1] {'0': 1024}
91it [00:04, 18.19it/s]
5 [0 1 0 1] 10 [1 0 1 0] {'1': 1024}
5 [0 1 0 1] 11 [1 0 1 1] {'1': 245, '0': 779}
93it [00:04, 17.74it/s]
5 [0 1 0 1] 12 [1 1 0 0] {'0': 1024}
5 [0 1 0 1] 13 [1 1 0 1] {'1': 262, '0': 762}
95it [00:05, 17.86it/s]
5 [0 1 0 1] 14 [1 1 1 0] {'1': 256, '0': 768}
97it [00:05, 14.83it/s]
5 [0 1 0 1] 15 [1 1 1 1] {'0': 1024}
6 [0 1 1 0] 0 [0 0 0 0] {'0': 1024}
100it [00:05, 16.44it/s]
6 [0 1 1 0] 1 [0 0 0 1] {'1': 242, '0': 782}
6 [0 1 1 0] 2 [0 0 1 0] {'1': 246, '0': 778}
6 [0 1 1 0] 3 [0 0 1 1] {'0': 1024}
6 [0 1 1 0] 4 [0 1 0 0] {'0': 760, '1': 264}
6 [0 1 1 0] 5 [0 1 0 1] {'0': 1024}
103it [00:05, 17.56it/s]
6 [0 1 1 0] 6 [0 1 1 0] {'1': 1024}
6 [0 1 1 0] 7 [0 1 1 1] {'0': 771, '1': 253}
6 [0 1 1 0] 8 [1 0 0 0] {'1': 248, '0': 776}
106it [00:05, 18.30it/s]
6 [0 1 1 0] 9 [1 0 0 1] {'1': 1024}
6 [0 1 1 0] 10 [1 0 1 0] {'0': 1024}
109it [00:05, 18.81it/s]
6 [0 1 1 0] 11 [1 0 1 1] {'1': 262, '0': 762}
6 [0 1 1 0] 12 [1 1 0 0] {'0': 1024}
111it [00:05, 18.58it/s]
6 [0 1 1 0] 13 [1 1 0 1] {'1': 246, '0': 778}
6 [0 1 1 0] 14 [1 1 1 0] {'1': 274, '0': 750}
113it [00:06, 18.39it/s]
6 [0 1 1 0] 15 [1 1 1 1] {'0': 1024}
7 [0 1 1 1] 0 [0 0 0 0] {'1': 259, '0': 765}
7 [0 1 1 1] 1 [0 0 0 1] {'0': 1024}
7 [0 1 1 1] 2 [0 0 1 0] {'0': 1024}
116it [00:06, 18.72it/s]
7 [0 1 1 1] 3 [0 0 1 1] {'1': 259, '0': 765}
7 [0 1 1 1] 4 [0 1 0 0] {'0': 1024}
118it [00:06, 18.71it/s]
7 [0 1 1 1] 5 [0 1 0 1] {'1': 244, '0': 780}
7 [0 1 1 1] 6 [0 1 1 0] {'0': 757, '1': 267}
120it [00:06, 18.79it/s]
7 [0 1 1 1] 7 [0 1 1 1] {'1': 1024}
7 [0 1 1 1] 8 [1 0 0 0] {'1': 1024}
122it [00:06, 18.63it/s]
7 [0 1 1 1] 9 [1 0 0 1] {'1': 247, '0': 777}
7 [0 1 1 1] 10 [1 0 1 0] {'0': 776, '1': 248}
124it [00:06, 18.55it/s]
7 [0 1 1 1] 11 [1 0 1 1] {'0': 1024}
7 [0 1 1 1] 12 [1 1 0 0] {'0': 753, '1': 271}
126it [00:06, 17.59it/s]
7 [0 1 1 1] 13 [1 1 0 1] {'0': 1024}
7 [0 1 1 1] 14 [1 1 1 0] {'0': 1024}
128it [00:06, 17.99it/s]
7 [0 1 1 1] 15 [1 1 1 1] {'1': 251, '0': 773}
8 [1 0 0 0] 0 [0 0 0 0] {'1': 242, '0': 782}
130it [00:06, 17.92it/s]
8 [1 0 0 0] 1 [0 0 0 1] {'0': 1024}
8 [1 0 0 0] 2 [0 0 1 0] {'0': 1024}
132it [00:07, 18.12it/s]
8 [1 0 0 0] 3 [0 0 1 1] {'1': 261, '0': 763}
8 [1 0 0 0] 4 [0 1 0 0] {'0': 1024}
134it [00:07, 17.57it/s]
8 [1 0 0 0] 5 [0 1 0 1] {'1': 265, '0': 759}
8 [1 0 0 0] 6 [0 1 1 0] {'0': 773, '1': 251}
136it [00:07, 16.95it/s]
8 [1 0 0 0] 7 [0 1 1 1] {'1': 1024}
8 [1 0 0 0] 8 [1 0 0 0] {'1': 1024}
138it [00:07, 17.31it/s]
8 [1 0 0 0] 9 [1 0 0 1] {'1': 282, '0': 742}
8 [1 0 0 0] 10 [1 0 1 0] {'1': 284, '0': 740}
140it [00:07, 17.70it/s]
8 [1 0 0 0] 11 [1 0 1 1] {'0': 1024}
8 [1 0 0 0] 12 [1 1 0 0] {'1': 253, '0': 771}
8 [1 0 0 0] 13 [1 1 0 1] {'0': 1024}
143it [00:07, 18.92it/s]
8 [1 0 0 0] 14 [1 1 1 0] {'0': 1024}
145it [00:07, 15.31it/s]
8 [1 0 0 0] 15 [1 1 1 1] {'0': 777, '1': 247}
9 [1 0 0 1] 0 [0 0 0 0] {'0': 1024}
148it [00:08, 16.69it/s]
9 [1 0 0 1] 1 [0 0 0 1] {'0': 760, '1': 264}
9 [1 0 0 1] 2 [0 0 1 0] {'1': 253, '0': 771}
9 [1 0 0 1] 3 [0 0 1 1] {'0': 1024}
150it [00:08, 17.21it/s]
9 [1 0 0 1] 4 [0 1 0 0] {'1': 264, '0': 760}
9 [1 0 0 1] 5 [0 1 0 1] {'0': 1024}
152it [00:08, 17.81it/s]
9 [1 0 0 1] 6 [0 1 1 0] {'1': 1024}
9 [1 0 0 1] 7 [0 1 1 1] {'1': 254, '0': 770}
9 [1 0 0 1] 8 [1 0 0 0] {'1': 270, '0': 754}
155it [00:08, 18.54it/s]
9 [1 0 0 1] 9 [1 0 0 1] {'1': 1024}
9 [1 0 0 1] 10 [1 0 1 0] {'0': 1024}
157it [00:08, 17.85it/s]
9 [1 0 0 1] 11 [1 0 1 1] {'1': 247, '0': 777}
9 [1 0 0 1] 12 [1 1 0 0] {'0': 1024}
159it [00:08, 18.29it/s]
9 [1 0 0 1] 13 [1 1 0 1] {'1': 250, '0': 774}
9 [1 0 0 1] 14 [1 1 1 0] {'0': 753, '1': 271}
161it [00:08, 18.55it/s]
9 [1 0 0 1] 15 [1 1 1 1] {'0': 1024}
10 [1 0 1 0] 0 [0 0 0 0] {'0': 1024}
163it [00:08, 17.87it/s]
10 [1 0 1 0] 1 [0 0 0 1] {'1': 287, '0': 737}
10 [1 0 1 0] 2 [0 0 1 0] {'1': 259, '0': 765}
165it [00:08, 17.96it/s]
10 [1 0 1 0] 3 [0 0 1 1] {'0': 1024}
10 [1 0 1 0] 4 [0 1 0 0] {'1': 254, '0': 770}
167it [00:09, 17.93it/s]
10 [1 0 1 0] 5 [0 1 0 1] {'1': 1024}
10 [1 0 1 0] 6 [0 1 1 0] {'0': 1024}
169it [00:09, 17.32it/s]
10 [1 0 1 0] 7 [0 1 1 1] {'1': 265, '0': 759}
10 [1 0 1 0] 8 [1 0 0 0] {'0': 765, '1': 259}
10 [1 0 1 0] 9 [1 0 0 1] {'0': 1024}
171it [00:09, 15.23it/s]
10 [1 0 1 0] 10 [1 0 1 0] {'1': 1024}
10 [1 0 1 0] 11 [1 0 1 1] {'1': 251, '0': 773}
173it [00:09, 15.19it/s]
10 [1 0 1 0] 12 [1 1 0 0] {'0': 1024}
10 [1 0 1 0] 13 [1 1 0 1] {'1': 257, '0': 767}
175it [00:09, 15.00it/s]
10 [1 0 1 0] 14 [1 1 1 0] {'1': 261, '0': 763}
10 [1 0 1 0] 15 [1 1 1 1] {'0': 1024}
177it [00:09, 16.13it/s]
11 [1 0 1 1] 0 [0 0 0 0] {'1': 247, '0': 777}
11 [1 0 1 1] 1 [0 0 0 1] {'0': 1024}
179it [00:09, 16.39it/s]
11 [1 0 1 1] 2 [0 0 1 0] {'0': 1024}
11 [1 0 1 1] 3 [0 0 1 1] {'0': 766, '1': 258}
181it [00:09, 15.77it/s]
11 [1 0 1 1] 4 [0 1 0 0] {'1': 1024}
11 [1 0 1 1] 5 [0 1 0 1] {'1': 258, '0': 766}
183it [00:10, 15.95it/s]
11 [1 0 1 1] 6 [0 1 1 0] {'1': 259, '0': 765}
11 [1 0 1 1] 7 [0 1 1 1] {'0': 1024}
185it [00:10, 16.65it/s]
11 [1 0 1 1] 8 [1 0 0 0] {'0': 1024}
11 [1 0 1 1] 9 [1 0 0 1] {'1': 265, '0': 759}
187it [00:10, 16.52it/s]
11 [1 0 1 1] 10 [1 0 1 0] {'1': 263, '0': 761}
11 [1 0 1 1] 11 [1 0 1 1] {'1': 1024}
189it [00:10, 17.40it/s]
11 [1 0 1 1] 12 [1 1 0 0] {'1': 256, '0': 768}
11 [1 0 1 1] 13 [1 1 0 1] {'0': 1024}
191it [00:10, 16.68it/s]
11 [1 0 1 1] 14 [1 1 1 0] {'0': 1024}
11 [1 0 1 1] 15 [1 1 1 1] {'1': 256, '0': 768}
12 [1 1 0 0] 0 [0 0 0 0] {'0': 1024}
196it [00:10, 15.77it/s]
12 [1 1 0 0] 1 [0 0 0 1] {'1': 267, '0': 757}
12 [1 1 0 0] 2 [0 0 1 0] {'1': 248, '0': 776}
12 [1 1 0 0] 3 [0 0 1 1] {'1': 1024}
198it [00:11, 16.65it/s]
12 [1 1 0 0] 4 [0 1 0 0] {'1': 275, '0': 749}
12 [1 1 0 0] 5 [0 1 0 1] {'0': 1024}
200it [00:11, 15.95it/s]
12 [1 1 0 0] 6 [0 1 1 0] {'0': 1024}
12 [1 1 0 0] 7 [0 1 1 1] {'1': 237, '0': 787}
202it [00:11, 15.85it/s]
12 [1 1 0 0] 8 [1 0 0 0] {'1': 268, '0': 756}
12 [1 1 0 0] 9 [1 0 0 1] {'0': 1024}
204it [00:11, 16.31it/s]
12 [1 1 0 0] 10 [1 0 1 0] {'0': 1024}
12 [1 1 0 0] 11 [1 0 1 1] {'1': 263, '0': 761}
206it [00:11, 15.84it/s]
12 [1 1 0 0] 12 [1 1 0 0] {'1': 1024}
12 [1 1 0 0] 13 [1 1 0 1] {'1': 244, '0': 780}
208it [00:11, 15.46it/s]
12 [1 1 0 0] 14 [1 1 1 0] {'1': 258, '0': 766}
12 [1 1 0 0] 15 [1 1 1 1] {'0': 1024}
13 [1 1 0 1] 0 [0 0 0 0] {'1': 259, '0': 765}
13 [1 1 0 1] 1 [0 0 0 1] {'0': 1024}
211it [00:11, 17.02it/s]
13 [1 1 0 1] 2 [0 0 1 0] {'1': 1024}
13 [1 1 0 1] 3 [0 0 1 1] {'1': 238, '0': 786}
213it [00:11, 17.26it/s]
13 [1 1 0 1] 4 [0 1 0 0] {'0': 1024}
13 [1 1 0 1] 5 [0 1 0 1] {'1': 247, '0': 777}
215it [00:12, 16.82it/s]
13 [1 1 0 1] 6 [0 1 1 0] {'1': 237, '0': 787}
13 [1 1 0 1] 7 [0 1 1 1] {'0': 1024}
217it [00:12, 17.28it/s]
13 [1 1 0 1] 8 [1 0 0 0] {'0': 1024}
13 [1 1 0 1] 9 [1 0 0 1] {'1': 255, '0': 769}
219it [00:12, 17.04it/s]
13 [1 1 0 1] 10 [1 0 1 0] {'1': 266, '0': 758}
13 [1 1 0 1] 11 [1 0 1 1] {'0': 1024}
221it [00:12, 16.95it/s]
13 [1 1 0 1] 12 [1 1 0 0] {'0': 773, '1': 251}
13 [1 1 0 1] 13 [1 1 0 1] {'1': 1024}
223it [00:12, 17.21it/s]
13 [1 1 0 1] 14 [1 1 1 0] {'0': 1024}
13 [1 1 0 1] 15 [1 1 1 1] {'1': 237, '0': 787}
225it [00:12, 17.00it/s]
14 [1 1 1 0] 0 [0 0 0 0] {'0': 761, '1': 263}
14 [1 1 1 0] 1 [0 0 0 1] {'1': 1024}
227it [00:12, 16.73it/s]
14 [1 1 1 0] 2 [0 0 1 0] {'0': 1024}
14 [1 1 1 0] 3 [0 0 1 1] {'0': 751, '1': 273}
229it [00:12, 16.74it/s]
14 [1 1 1 0] 4 [0 1 0 0] {'0': 1024}
14 [1 1 1 0] 5 [0 1 0 1] {'1': 264, '0': 760}
231it [00:12, 16.73it/s]
14 [1 1 1 0] 6 [0 1 1 0] {'1': 262, '0': 762}
14 [1 1 1 0] 7 [0 1 1 1] {'0': 1024}
233it [00:13, 16.87it/s]
14 [1 1 1 0] 8 [1 0 0 0] {'0': 1024}
14 [1 1 1 0] 9 [1 0 0 1] {'0': 726, '1': 298}
235it [00:13, 17.65it/s]
14 [1 1 1 0] 10 [1 0 1 0] {'1': 256, '0': 768}
14 [1 1 1 0] 11 [1 0 1 1] {'0': 1024}
239it [00:13, 13.85it/s]
14 [1 1 1 0] 12 [1 1 0 0] {'1': 254, '0': 770}
14 [1 1 1 0] 13 [1 1 0 1] {'0': 1024}
14 [1 1 1 0] 14 [1 1 1 0] {'1': 1024}
14 [1 1 1 0] 15 [1 1 1 1] {'0': 772, '1': 252}
243it [00:13, 15.00it/s]
15 [1 1 1 1] 0 [0 0 0 0] {'1': 1024}
15 [1 1 1 1] 1 [0 0 0 1] {'1': 257, '0': 767}
15 [1 1 1 1] 2 [0 0 1 0] {'1': 265, '0': 759}
15 [1 1 1 1] 3 [0 0 1 1] {'0': 1024}
247it [00:14, 15.18it/s]
15 [1 1 1 1] 4 [0 1 0 0] {'0': 760, '1': 264}
15 [1 1 1 1] 5 [0 1 0 1] {'0': 1024}
15 [1 1 1 1] 6 [0 1 1 0] {'0': 1024}
251it [00:14, 15.43it/s]
15 [1 1 1 1] 7 [0 1 1 1] {'1': 243, '0': 781}
15 [1 1 1 1] 8 [1 0 0 0] {'1': 249, '0': 775}
15 [1 1 1 1] 9 [1 0 0 1] {'0': 1024}
15 [1 1 1 1] 10 [1 0 1 0] {'0': 1024}
255it [00:14, 15.92it/s]
15 [1 1 1 1] 11 [1 0 1 1] {'0': 760, '1': 264}
15 [1 1 1 1] 12 [1 1 0 0] {'0': 1024}
15 [1 1 1 1] 13 [1 1 0 1] {'1': 253, '0': 771}
15 [1 1 1 1] 14 [1 1 1 0] {'0': 763, '1': 261}
256it [00:14, 17.47it/s]
15 [1 1 1 1] 15 [1 1 1 1] {'1': 1024}
In [36]:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.set_xlabel("weight")
ax.set_ylabel("input")
out_plot = ax.imshow(outcomes, cmap='Blues', interpolation='none')
fig.colorbar(out_plot, ax=ax)
Out[36]:
<matplotlib.colorbar.Colorbar at 0x737894265fd0>
In [ ]: