Skip to content

Commit 87a8478

Browse files
author
JiaceSun
committed
add abstract circuit
1 parent f41b70f commit 87a8478

30 files changed

+737
-676
lines changed

benchmarks/scripts/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ def processing(train_img, test_img, train_lbl, test_lbl):
183183
pca.fit(train_img)
184184
train_img = pca.transform(train_img)
185185
test_img = pca.transform(test_img)
186-
train_img = np.array([x / np.sqrt(np.sum(x**2)) for x in train_img])
187-
test_img = np.array([x / np.sqrt(np.sum(x**2)) for x in test_img])
186+
train_img = np.array([x / np.sqrt(np.sum(x ** 2)) for x in train_img])
187+
test_img = np.array([x / np.sqrt(np.sum(x ** 2)) for x in test_img])
188188
qml_data["test_img"] = test_img
189189
qml_data["train_img"] = train_img
190190
qml_data["train_lbl"] = train_lbl

examples/checkpoint_memsave.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def totallayer(s, param):
9797

9898

9999
def vqe_forward(param):
100-
s = tc.backend.ones([2**nwires])
100+
s = tc.backend.ones([2 ** nwires])
101101
s /= tc.backend.norm(s)
102102
s = totallayer(s, param)
103103
e = tc.expectation((tc.gates.x(), [1]), ket=s)

examples/hchainhamiltonian.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import time
66
import tensorflow as tf
7+
from scipy import sparse
78
from openfermion.chem import MolecularData
89
from openfermion.transforms import (
910
get_fermion_operator,
@@ -14,7 +15,6 @@
1415
)
1516
from openfermion.utils import up_then_down
1617
from openfermionpyscf import run_pyscf
17-
from scipy import sparse
1818

1919
import tensorcircuit as tc
2020

examples/quantumng.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
sys.path.insert(0, "../")
99

10-
import optax
1110
import tensorflow as tf
11+
import optax
1212

1313
import tensorcircuit as tc
1414
from tensorcircuit import experimental

examples/variational_dynamics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def update(theta, lhs, rhs, tau):
9696
# TFIM Hamiltonian defined on lattice graph g (1D OBC chain)
9797
h = tc.array_to_tensor(h)
9898

99-
psi0 = np.zeros(2**N)
99+
psi0 = np.zeros(2 ** N)
100100
psi0[0] = 1.0
101101
psi0 = tc.array_to_tensor(psi0)
102102

examples/variational_dynamics_generalized.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def update(theta, lhs, rhs, tau):
116116
# TFIM Hamiltonian defined on lattice graph g (1D OBC chain)
117117
h = tc.array_to_tensor(h)
118118

119-
psi0 = np.zeros(2**N)
119+
psi0 = np.zeros(2 ** N)
120120
psi0[0] = 1.0
121121
psi0 = tc.array_to_tensor(psi0)
122122

examples/vqeh2o_benchmark.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
mb = tc.quantum.PauliStringSum2COO_numpy(lsb, wb)
4242
mbd = mb.todense()
4343
mb = K.coo_sparse_matrix(
44-
np.transpose(np.stack([mb.row, mb.col])), mb.data, shape=(2**n, 2**n)
44+
np.transpose(np.stack([mb.row, mb.col])), mb.data, shape=(2 ** n, 2 ** n)
4545
)
4646
mbd = tc.array_to_tensor(mbd)
4747

examples/vqetfim_benchmark.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def vqe_template(param, op):
115115
np.stack([hamiltonian_sparse_numpy.row, hamiltonian_sparse_numpy.col])
116116
),
117117
hamiltonian_sparse_numpy.data,
118-
shape=(2**n, 2**n),
118+
shape=(2 ** n, 2 ** n),
119119
)
120120

121121
if enable_dense is True:

0 commit comments

Comments
 (0)