@@ -96,7 +96,7 @@ def vqe_forward(param, structures):
96
96
time0 = time .time ()
97
97
98
98
batch = 50
99
- tc_vag = tf .function (
99
+ tc_vg = tf .function (
100
100
tc .backend .vectorized_value_and_grad (vqe_forward , argnums = 0 , vectorized_argnums = 1 ),
101
101
input_signature = [
102
102
tf .TensorSpec ([2 * nlayers , nwires ], tf .float32 ),
@@ -105,23 +105,23 @@ def vqe_forward(param, structures):
105
105
)
106
106
param = tf .Variable (tf .random .normal (stddev = 0.1 , shape = [2 * nlayers , nwires ]))
107
107
108
- print (tc_vag (param , structures [:batch ]))
108
+ print (tc_vg (param , structures [:batch ]))
109
109
110
110
time1 = time .time ()
111
111
print ("staging time: " , time1 - time0 )
112
112
113
113
try :
114
- keras .save_func (tc_vag , "./funcs/%s_%s_10_tfim" % (nwires , nlayers ))
114
+ keras .save_func (tc_vg , "./funcs/%s_%s_10_tfim" % (nwires , nlayers ))
115
115
except ValueError as e :
116
116
print (e ) # keras.save_func now has issues to be resolved
117
117
118
118
119
119
def train_step (param ):
120
- vag_list = []
120
+ vg_list = []
121
121
for i in range (2 ):
122
- vag_list .append (tc_vag (param , structures [i * nwires : i * nwires + nwires ]))
123
- loss = tc .backend .sum (vag_list [0 ][0 ] - vag_list [1 ][0 ])
124
- gr = vag_list [0 ][1 ] - vag_list [1 ][1 ]
122
+ vg_list .append (tc_vg (param , structures [i * nwires : i * nwires + nwires ]))
123
+ loss = tc .backend .sum (vg_list [0 ][0 ] - vg_list [1 ][0 ])
124
+ gr = vg_list [0 ][1 ] - vg_list [1 ][1 ]
125
125
return loss , gr
126
126
127
127
0 commit comments