pyqrack-complex128 1.78.3__py3-none-macosx_14_0_arm64.whl → 1.82.0__py3-none-macosx_14_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pyqrack-complex128 might be problematic. Click here for more details.
- pyqrack/__init__.py +0 -1
- pyqrack/qrack_ace_backend.py +16 -46
- pyqrack/qrack_circuit.py +2 -6
- pyqrack/qrack_neuron.py +67 -36
- pyqrack/qrack_neuron_torch_layer.py +132 -235
- pyqrack/qrack_simulator.py +106 -189
- pyqrack/qrack_system/qrack_lib/{libqrack_pinvoke.9.34.5.dylib → libqrack_pinvoke.10.0.0.dylib} +0 -0
- pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.dylib +0 -0
- pyqrack/qrack_system/qrack_system.py +68 -59
- pyqrack/stats/load_quantized_data.py +1 -3
- pyqrack/stats/quantize_by_range.py +2 -6
- {pyqrack_complex128-1.78.3.dist-info → pyqrack_complex128-1.82.0.dist-info}/METADATA +3 -1
- pyqrack_complex128-1.82.0.dist-info/RECORD +23 -0
- pyqrack_complex128-1.78.3.dist-info/RECORD +0 -23
- {pyqrack_complex128-1.78.3.dist-info → pyqrack_complex128-1.82.0.dist-info}/LICENSE +0 -0
- {pyqrack_complex128-1.78.3.dist-info → pyqrack_complex128-1.82.0.dist-info}/WHEEL +0 -0
- {pyqrack_complex128-1.78.3.dist-info → pyqrack_complex128-1.82.0.dist-info}/top_level.txt +0 -0
pyqrack/__init__.py
CHANGED
pyqrack/qrack_ace_backend.py
CHANGED
|
@@ -224,9 +224,7 @@ class QrackAceBackend:
|
|
|
224
224
|
isPaged=True,
|
|
225
225
|
isCpuGpuHybrid=True,
|
|
226
226
|
isOpenCL=True,
|
|
227
|
-
isHostPointer=(
|
|
228
|
-
True if os.environ.get("PYQRACK_HOST_POINTER_DEFAULT_ON") else False
|
|
229
|
-
),
|
|
227
|
+
isHostPointer=(True if os.environ.get("PYQRACK_HOST_POINTER_DEFAULT_ON") else False),
|
|
230
228
|
noise=0,
|
|
231
229
|
toClone=None,
|
|
232
230
|
):
|
|
@@ -294,11 +292,7 @@ class QrackAceBackend:
|
|
|
294
292
|
sim_counts[t_sim_id] += 1
|
|
295
293
|
|
|
296
294
|
qubit.append(
|
|
297
|
-
LHVQubit(
|
|
298
|
-
toClone=(
|
|
299
|
-
toClone._qubits[tot_qubits][2] if toClone else None
|
|
300
|
-
)
|
|
301
|
-
)
|
|
295
|
+
LHVQubit(toClone=(toClone._qubits[tot_qubits][2] if toClone else None))
|
|
302
296
|
)
|
|
303
297
|
|
|
304
298
|
if (not c) and (not r):
|
|
@@ -545,9 +539,7 @@ class QrackAceBackend:
|
|
|
545
539
|
self.sim[hq[4][0]].prob(hq[4][1]),
|
|
546
540
|
]
|
|
547
541
|
# Balancing suggestion from Elara (the custom OpenAI GPT)
|
|
548
|
-
prms = math.sqrt(
|
|
549
|
-
(p[0] ** 2 + p[1] ** 2 + 3 * (p[2] ** 2) + p[3] ** 2 + p[4] ** 2) / 7
|
|
550
|
-
)
|
|
542
|
+
prms = math.sqrt((p[0] ** 2 + p[1] ** 2 + 3 * (p[2] ** 2) + p[3] ** 2 + p[4] ** 2) / 7)
|
|
551
543
|
qrms = math.sqrt(
|
|
552
544
|
(
|
|
553
545
|
(1 - p[0]) ** 2
|
|
@@ -860,9 +852,7 @@ class QrackAceBackend:
|
|
|
860
852
|
gate = self.sim[sim_id].macz if anti else self.sim[sim_id].mcz
|
|
861
853
|
shadow = self._anti_cz_shadow if anti else self._cz_shadow
|
|
862
854
|
else:
|
|
863
|
-
raise RuntimeError(
|
|
864
|
-
"QrackAceBackend._get_gate() should never return identity!"
|
|
865
|
-
)
|
|
855
|
+
raise RuntimeError("QrackAceBackend._get_gate() should never return identity!")
|
|
866
856
|
|
|
867
857
|
return gate, shadow
|
|
868
858
|
|
|
@@ -899,11 +889,7 @@ class QrackAceBackend:
|
|
|
899
889
|
b2 = hq2[q2]
|
|
900
890
|
if b1[0] == b2[0]:
|
|
901
891
|
gate_fn([b1[1]], b2[1])
|
|
902
|
-
elif (
|
|
903
|
-
lq1_lr
|
|
904
|
-
or (b1[1] == b2[1])
|
|
905
|
-
or ((len(qb1) == 2) and (b1[1] == (b2[1] & 1)))
|
|
906
|
-
):
|
|
892
|
+
elif lq1_lr or (b1[1] == b2[1]) or ((len(qb1) == 2) and (b1[1] == (b2[1] & 1))):
|
|
907
893
|
shadow_fn(b1, b2)
|
|
908
894
|
|
|
909
895
|
def _cpauli(self, lq1, lq2, anti, pauli):
|
|
@@ -1033,9 +1019,7 @@ class QrackAceBackend:
|
|
|
1033
1019
|
self.sim[hq[4][0]].prob(hq[4][1]),
|
|
1034
1020
|
]
|
|
1035
1021
|
# Balancing suggestion from Elara (the custom OpenAI GPT)
|
|
1036
|
-
prms = math.sqrt(
|
|
1037
|
-
(p[0] ** 2 + p[1] ** 2 + 3 * (p[2] ** 2) + p[3] ** 2 + p[4] ** 2) / 7
|
|
1038
|
-
)
|
|
1022
|
+
prms = math.sqrt((p[0] ** 2 + p[1] ** 2 + 3 * (p[2] ** 2) + p[3] ** 2 + p[4] ** 2) / 7)
|
|
1039
1023
|
qrms = math.sqrt(
|
|
1040
1024
|
(
|
|
1041
1025
|
(1 - p[0]) ** 2
|
|
@@ -1187,17 +1171,11 @@ class QrackAceBackend:
|
|
|
1187
1171
|
(-1 * float(operation.params[1])) + math.pi / 2,
|
|
1188
1172
|
)
|
|
1189
1173
|
elif name == "rx":
|
|
1190
|
-
self._sim.r(
|
|
1191
|
-
Pauli.PauliX, float(operation.params[0]), operation.qubits[0]._index
|
|
1192
|
-
)
|
|
1174
|
+
self._sim.r(Pauli.PauliX, float(operation.params[0]), operation.qubits[0]._index)
|
|
1193
1175
|
elif name == "ry":
|
|
1194
|
-
self._sim.r(
|
|
1195
|
-
Pauli.PauliY, float(operation.params[0]), operation.qubits[0]._index
|
|
1196
|
-
)
|
|
1176
|
+
self._sim.r(Pauli.PauliY, float(operation.params[0]), operation.qubits[0]._index)
|
|
1197
1177
|
elif name == "rz":
|
|
1198
|
-
self._sim.r(
|
|
1199
|
-
Pauli.PauliZ, float(operation.params[0]), operation.qubits[0]._index
|
|
1200
|
-
)
|
|
1178
|
+
self._sim.r(Pauli.PauliZ, float(operation.params[0]), operation.qubits[0]._index)
|
|
1201
1179
|
elif name == "h":
|
|
1202
1180
|
self._sim.h(operation.qubits[0]._index)
|
|
1203
1181
|
elif name == "x":
|
|
@@ -1262,9 +1240,9 @@ class QrackAceBackend:
|
|
|
1262
1240
|
cregbit = clbit
|
|
1263
1241
|
|
|
1264
1242
|
regbit = 1 << cregbit
|
|
1265
|
-
self._classical_register = (
|
|
1266
|
-
|
|
1267
|
-
)
|
|
1243
|
+
self._classical_register = (self._classical_register & (~regbit)) | (
|
|
1244
|
+
qubit_outcome << cregbit
|
|
1245
|
+
)
|
|
1268
1246
|
|
|
1269
1247
|
elif name == "bfunc":
|
|
1270
1248
|
mask = int(operation.mask, 16)
|
|
@@ -1379,9 +1357,7 @@ class QrackAceBackend:
|
|
|
1379
1357
|
if operation.name == "id" or operation.name == "barrier":
|
|
1380
1358
|
continue
|
|
1381
1359
|
|
|
1382
|
-
if is_initializing and (
|
|
1383
|
-
(operation.name == "measure") or (operation.name == "reset")
|
|
1384
|
-
):
|
|
1360
|
+
if is_initializing and ((operation.name == "measure") or (operation.name == "reset")):
|
|
1385
1361
|
continue
|
|
1386
1362
|
|
|
1387
1363
|
is_initializing = False
|
|
@@ -1439,9 +1415,7 @@ class QrackAceBackend:
|
|
|
1439
1415
|
self._sample_cregbits = []
|
|
1440
1416
|
|
|
1441
1417
|
if self._sample_measure and (len(self._sample_qubits) > 0):
|
|
1442
|
-
_data = self._add_sample_measure(
|
|
1443
|
-
self._sample_qubits, self._sample_clbits, self._shots
|
|
1444
|
-
)
|
|
1418
|
+
_data = self._add_sample_measure(self._sample_qubits, self._sample_clbits, self._shots)
|
|
1445
1419
|
|
|
1446
1420
|
del self._sim
|
|
1447
1421
|
|
|
@@ -1532,17 +1506,13 @@ class QrackAceBackend:
|
|
|
1532
1506
|
noise_model.add_quantum_error(depolarizing_error(y, 2), "cx", [a, b])
|
|
1533
1507
|
noise_model.add_quantum_error(depolarizing_error(y_cy, 2), "cy", [a, b])
|
|
1534
1508
|
noise_model.add_quantum_error(depolarizing_error(y_cy, 2), "cz", [a, b])
|
|
1535
|
-
noise_model.add_quantum_error(
|
|
1536
|
-
depolarizing_error(y_swap, 2), "swap", [a, b]
|
|
1537
|
-
)
|
|
1509
|
+
noise_model.add_quantum_error(depolarizing_error(y_swap, 2), "swap", [a, b])
|
|
1538
1510
|
else:
|
|
1539
1511
|
y_cy = 1 - (1 - y) ** 2
|
|
1540
1512
|
y_swap = 1 - (1 - y) ** 3
|
|
1541
1513
|
noise_model.add_quantum_error(depolarizing_error(y_cy, 2), "cx", [a, b])
|
|
1542
1514
|
noise_model.add_quantum_error(depolarizing_error(y_cy, 2), "cy", [a, b])
|
|
1543
1515
|
noise_model.add_quantum_error(depolarizing_error(y_cy, 2), "cz", [a, b])
|
|
1544
|
-
noise_model.add_quantum_error(
|
|
1545
|
-
depolarizing_error(y_swap, 2), "swap", [a, b]
|
|
1546
|
-
)
|
|
1516
|
+
noise_model.add_quantum_error(depolarizing_error(y_swap, 2), "swap", [a, b])
|
|
1547
1517
|
|
|
1548
1518
|
return noise_model
|
pyqrack/qrack_circuit.py
CHANGED
|
@@ -507,9 +507,7 @@ class QrackCircuit:
|
|
|
507
507
|
)
|
|
508
508
|
if circuit_type == QuimbCircuitType.Circuit
|
|
509
509
|
else (
|
|
510
|
-
qtn.CircuitDense(
|
|
511
|
-
N=qcirc.num_qubits, psi0=psi0, gate_opts=gate_opts, tags=tags
|
|
512
|
-
)
|
|
510
|
+
qtn.CircuitDense(N=qcirc.num_qubits, psi0=psi0, gate_opts=gate_opts, tags=tags)
|
|
513
511
|
if circuit_type == QuimbCircuitType.CircuitDense
|
|
514
512
|
else qtn.CircuitMPS(
|
|
515
513
|
N=qcirc.num_qubits,
|
|
@@ -540,9 +538,7 @@ class QrackCircuit:
|
|
|
540
538
|
return tcirc
|
|
541
539
|
|
|
542
540
|
@staticmethod
|
|
543
|
-
def file_to_tensorcircuit(
|
|
544
|
-
filename, inputs=None, circuit_params=None, binding_params=None
|
|
545
|
-
):
|
|
541
|
+
def file_to_tensorcircuit(filename, inputs=None, circuit_params=None, binding_params=None):
|
|
546
542
|
"""Convert an output file to a TensorCircuit circuit
|
|
547
543
|
|
|
548
544
|
Reads in an (optimized) circuit from a file named
|
pyqrack/qrack_neuron.py
CHANGED
|
@@ -31,7 +31,9 @@ class QrackNeuron:
|
|
|
31
31
|
simulator(QrackSimulator): Simulator instance for all synaptic clefts of the neuron
|
|
32
32
|
controls(list(int)): Indices of all "control" qubits, for neuron input
|
|
33
33
|
target(int): Index of "target" qubit, for neuron output
|
|
34
|
-
|
|
34
|
+
activation_fn(NeuronActivationFn): Activation function choice
|
|
35
|
+
alpha(float): Activation function parameter, if required
|
|
36
|
+
angles(list[ctypes.c_float]): (or c_double) Memory for neuron prediction angles
|
|
35
37
|
"""
|
|
36
38
|
|
|
37
39
|
def _get_error(self):
|
|
@@ -48,7 +50,6 @@ class QrackNeuron:
|
|
|
48
50
|
target,
|
|
49
51
|
activation_fn=NeuronActivationFn.Sigmoid,
|
|
50
52
|
alpha=1.0,
|
|
51
|
-
tolerance=sys.float_info.epsilon,
|
|
52
53
|
_init=True,
|
|
53
54
|
):
|
|
54
55
|
self.simulator = simulator
|
|
@@ -56,7 +57,7 @@ class QrackNeuron:
|
|
|
56
57
|
self.target = target
|
|
57
58
|
self.activation_fn = activation_fn
|
|
58
59
|
self.alpha = alpha
|
|
59
|
-
self.
|
|
60
|
+
self.angles = QrackNeuron._real1_byref([0.0] * (1 << len(controls)))
|
|
60
61
|
|
|
61
62
|
if not _init:
|
|
62
63
|
return
|
|
@@ -66,9 +67,6 @@ class QrackNeuron:
|
|
|
66
67
|
len(controls),
|
|
67
68
|
QrackNeuron._ulonglong_byref(controls),
|
|
68
69
|
target,
|
|
69
|
-
activation_fn,
|
|
70
|
-
alpha,
|
|
71
|
-
tolerance,
|
|
72
70
|
)
|
|
73
71
|
|
|
74
72
|
self._throw_if_error()
|
|
@@ -91,11 +89,9 @@ class QrackNeuron:
|
|
|
91
89
|
self.simulator,
|
|
92
90
|
self.controls,
|
|
93
91
|
self.target,
|
|
94
|
-
self.activation_fn,
|
|
95
|
-
self.alpha,
|
|
96
|
-
self.tolerance,
|
|
97
92
|
)
|
|
98
|
-
|
|
93
|
+
result.nid = Qrack.qrack_lib.clone_qneuron(self.simulator.sid)
|
|
94
|
+
result.angles = self.angles[:]
|
|
99
95
|
self._throw_if_error()
|
|
100
96
|
return result
|
|
101
97
|
|
|
@@ -110,6 +106,51 @@ class QrackNeuron:
|
|
|
110
106
|
return (ctypes.c_float * len(a))(*a)
|
|
111
107
|
return (ctypes.c_double * len(a))(*a)
|
|
112
108
|
|
|
109
|
+
def set_simulator(self, s, controls=None, target=None):
|
|
110
|
+
"""Set the neuron simulator
|
|
111
|
+
|
|
112
|
+
Set the simulator used by this neuron
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
s(QrackSimulator): The simulator to use
|
|
116
|
+
controls(list[int]): The control qubit IDs to use
|
|
117
|
+
target(int): The output qubit ID to use
|
|
118
|
+
|
|
119
|
+
Raises:
|
|
120
|
+
RuntimeError: QrackSimulator raised an exception.
|
|
121
|
+
"""
|
|
122
|
+
if controls is None:
|
|
123
|
+
controls = self.controls
|
|
124
|
+
if target is None:
|
|
125
|
+
target = self.target
|
|
126
|
+
Qrack.qrack_lib.set_qneuron_sim(
|
|
127
|
+
self.nid,
|
|
128
|
+
s.sid,
|
|
129
|
+
len(controls),
|
|
130
|
+
QrackNeuron._ulonglong_byref(controls),
|
|
131
|
+
target,
|
|
132
|
+
)
|
|
133
|
+
self._throw_if_error()
|
|
134
|
+
self.simulator = s
|
|
135
|
+
self.controls = controls
|
|
136
|
+
self.target = target
|
|
137
|
+
|
|
138
|
+
def set_qubit_ids(self, controls, target=None):
|
|
139
|
+
"""Set the neuron qubit identifiers
|
|
140
|
+
|
|
141
|
+
Set the control and target qubits within the simulator
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
controls(list[int]): The control qubit IDs to use
|
|
145
|
+
target(int): The output qubit ID to use
|
|
146
|
+
|
|
147
|
+
Raises:
|
|
148
|
+
RuntimeError: QrackSimulator raised an exception.
|
|
149
|
+
"""
|
|
150
|
+
if target is None:
|
|
151
|
+
target = self.target
|
|
152
|
+
self.set_simulator(self.simulator, controls, target)
|
|
153
|
+
|
|
113
154
|
def set_angles(self, a):
|
|
114
155
|
"""Directly sets the neuron parameters.
|
|
115
156
|
|
|
@@ -127,8 +168,7 @@ class QrackNeuron:
|
|
|
127
168
|
raise ValueError(
|
|
128
169
|
"Angles 'a' in QrackNeuron.set_angles() must contain at least (2 ** len(self.controls)) elements."
|
|
129
170
|
)
|
|
130
|
-
|
|
131
|
-
self._throw_if_error()
|
|
171
|
+
self.angles = QrackNeuron._real1_byref(a)
|
|
132
172
|
|
|
133
173
|
def get_angles(self):
|
|
134
174
|
"""Directly gets the neuron parameters.
|
|
@@ -139,10 +179,7 @@ class QrackNeuron:
|
|
|
139
179
|
Raises:
|
|
140
180
|
RuntimeError: QrackNeuron C++ library raised an exception.
|
|
141
181
|
"""
|
|
142
|
-
|
|
143
|
-
Qrack.qrack_lib.get_qneuron_angles(self.nid, ket)
|
|
144
|
-
self._throw_if_error()
|
|
145
|
-
return list(ket)
|
|
182
|
+
return list(self.angles)
|
|
146
183
|
|
|
147
184
|
def set_alpha(self, a):
|
|
148
185
|
"""Set the neuron 'alpha' parameter.
|
|
@@ -151,13 +188,8 @@ class QrackNeuron:
|
|
|
151
188
|
parameter that is applied as a power to its angles, before
|
|
152
189
|
learning and prediction. This makes the activation function
|
|
153
190
|
sharper (or less sharp).
|
|
154
|
-
|
|
155
|
-
Raises:
|
|
156
|
-
RuntimeError: QrackNeuron C++ library raised an exception.
|
|
157
191
|
"""
|
|
158
192
|
self.alpha = a
|
|
159
|
-
Qrack.qrack_lib.set_qneuron_alpha(self.nid, a)
|
|
160
|
-
self._throw_if_error()
|
|
161
193
|
|
|
162
194
|
def set_activation_fn(self, f):
|
|
163
195
|
"""Sets the activation function of this QrackNeuron
|
|
@@ -165,13 +197,8 @@ class QrackNeuron:
|
|
|
165
197
|
Nonlinear activation functions can be important to neural net
|
|
166
198
|
applications, like DNN. The available activation functions are
|
|
167
199
|
enumerated in `NeuronActivationFn`.
|
|
168
|
-
|
|
169
|
-
Raises:
|
|
170
|
-
RuntimeError: QrackNeuron C++ library raised an exception.
|
|
171
200
|
"""
|
|
172
201
|
self.activation_fn = f
|
|
173
|
-
Qrack.qrack_lib.set_qneuron_activation_fn(self.nid, f)
|
|
174
|
-
self._throw_if_error()
|
|
175
202
|
|
|
176
203
|
def predict(self, e=True, r=True):
|
|
177
204
|
"""Predict based on training
|
|
@@ -190,7 +217,7 @@ class QrackNeuron:
|
|
|
190
217
|
Raises:
|
|
191
218
|
RuntimeError: QrackNeuron C++ library raised an exception.
|
|
192
219
|
"""
|
|
193
|
-
result = Qrack.qrack_lib.qneuron_predict(self.nid, e, r)
|
|
220
|
+
result = Qrack.qrack_lib.qneuron_predict(self.nid, self.angles, e, r, self.activation_fn, self.alpha)
|
|
194
221
|
self._throw_if_error()
|
|
195
222
|
return result
|
|
196
223
|
|
|
@@ -206,7 +233,7 @@ class QrackNeuron:
|
|
|
206
233
|
Raises:
|
|
207
234
|
RuntimeError: QrackNeuron C++ library raised an exception.
|
|
208
235
|
"""
|
|
209
|
-
result = Qrack.qrack_lib.qneuron_unpredict(self.nid, e)
|
|
236
|
+
result = Qrack.qrack_lib.qneuron_unpredict(self.nid, self.angles, e, self.activation_fn, self.alpha)
|
|
210
237
|
self._throw_if_error()
|
|
211
238
|
return result
|
|
212
239
|
|
|
@@ -222,7 +249,7 @@ class QrackNeuron:
|
|
|
222
249
|
Raises:
|
|
223
250
|
RuntimeError: QrackNeuron C++ library raised an exception.
|
|
224
251
|
"""
|
|
225
|
-
Qrack.qrack_lib.qneuron_learn_cycle(self.nid, e)
|
|
252
|
+
Qrack.qrack_lib.qneuron_learn_cycle(self.nid, self.angles, e, self.activation_fn, self.alpha)
|
|
226
253
|
self._throw_if_error()
|
|
227
254
|
|
|
228
255
|
def learn(self, eta, e=True, r=True):
|
|
@@ -241,7 +268,7 @@ class QrackNeuron:
|
|
|
241
268
|
Raises:
|
|
242
269
|
RuntimeError: QrackNeuron C++ library raised an exception.
|
|
243
270
|
"""
|
|
244
|
-
Qrack.qrack_lib.qneuron_learn(self.nid, eta, e, r)
|
|
271
|
+
Qrack.qrack_lib.qneuron_learn(self.nid, self.angles, eta, e, r, self.activation_fn, self.alpha)
|
|
245
272
|
self._throw_if_error()
|
|
246
273
|
|
|
247
274
|
def learn_permutation(self, eta, e=True, r=True):
|
|
@@ -260,12 +287,12 @@ class QrackNeuron:
|
|
|
260
287
|
Raises:
|
|
261
288
|
RuntimeError: QrackNeuron C++ library raised an exception.
|
|
262
289
|
"""
|
|
263
|
-
Qrack.qrack_lib.qneuron_learn_permutation(self.nid, eta, e, r)
|
|
290
|
+
Qrack.qrack_lib.qneuron_learn_permutation(self.nid, self.angles, eta, e, r, self.activation_fn, self.alpha)
|
|
264
291
|
self._throw_if_error()
|
|
265
292
|
|
|
266
293
|
@staticmethod
|
|
267
294
|
def quantile_bounds(vec, bits):
|
|
268
|
-
"""
|
|
295
|
+
"""Calculate vector quantile bounds
|
|
269
296
|
|
|
270
297
|
This is a static helper method to calculate the quantile
|
|
271
298
|
bounds of 2 ** bits worth of quantiles.
|
|
@@ -283,11 +310,15 @@ class QrackNeuron:
|
|
|
283
310
|
n = len(vec)
|
|
284
311
|
vec_sorted = sorted(vec)
|
|
285
312
|
|
|
286
|
-
return
|
|
313
|
+
return (
|
|
314
|
+
[vec_sorted[0]]
|
|
315
|
+
+ [vec_sorted[(k * n) // bins] for k in range(1, bins)]
|
|
316
|
+
+ [vec_sorted[-1]]
|
|
317
|
+
)
|
|
287
318
|
|
|
288
319
|
@staticmethod
|
|
289
320
|
def discretize(vec, bounds):
|
|
290
|
-
"""
|
|
321
|
+
"""Discretize vector by quantile bounds
|
|
291
322
|
|
|
292
323
|
This is a static helper method to discretize a numerical
|
|
293
324
|
vector according to quantile bounds calculated by the
|
|
@@ -317,7 +348,7 @@ class QrackNeuron:
|
|
|
317
348
|
|
|
318
349
|
@staticmethod
|
|
319
350
|
def flatten_and_transpose(arr):
|
|
320
|
-
"""
|
|
351
|
+
"""Flatten and transpose feature matrix
|
|
321
352
|
|
|
322
353
|
This is a static helper method to convert a multi-feature
|
|
323
354
|
bit-row matrix to an observation-row matrix with flat
|
|
@@ -333,7 +364,7 @@ class QrackNeuron:
|
|
|
333
364
|
|
|
334
365
|
@staticmethod
|
|
335
366
|
def bin_endpoints_average(bounds):
|
|
336
|
-
"""
|
|
367
|
+
"""Bin endpoints average
|
|
337
368
|
|
|
338
369
|
This is a static helper method that accepts the output
|
|
339
370
|
bins from quantile_bounds() and returns the average points
|