Exemplo n.º 1
0
 def __init__(self, fm_x, fm_y, dim_x, dim_y):
     super(QMRegressor, self).__init__()
     self.fm_x = fm_x
     self.fm_y = fm_y
     self.qm = layers.QMeasureClassif(dim_x=dim_x, dim_y=dim_y)
     self.dmregress = layers.DensityMatrixRegression()
     self.cp1 = layers.CrossProduct()
     self.cp2 = layers.CrossProduct()
     self.num_samples = tf.Variable(initial_value=0., trainable=False)
Exemplo n.º 2
0
 def __init__(self, input_dim, dim_x, dim_y, num_eig=0, gamma=1, random_state=None):
     super(QMRegressorSGD, self).__init__()
     self.fm_x = layers.QFeatureMapRFF(
         input_dim=input_dim,
         dim=dim_x, gamma=gamma, random_state=random_state)
     self.qm = layers.QMeasureClassifEig(dim_x=dim_x, dim_y=dim_y, num_eig=num_eig)
     self.dmregress = layers.DensityMatrixRegression()
     self.dim_x = dim_x
     self.dim_y = dim_y
     self.gamma = gamma
     self.random_state = random_state
Exemplo n.º 3
0
qmc2.compile(optimizer, loss=tf.keras.losses.CategoricalCrossentropy())
train_y = tf.reshape(tf.keras.backend.one_hot(data_y, 2), (4, 2))
qmc2.fit(data_x, train_y, epochs=20)
out2 = qmc2(data_x)
print(out2)

out = qmc.call_train(data_x, data_y)
print(out)
qmc.train_step((data_x, data_y))

inputs = tf.ones((2, 3))
qfm = layers.QFeatureMapRFF()
out1 = qfm(inputs)
print(out1)

inputs = tf.ones((2, 3))
qfm = layers.QFeatureMapSmp(dim=2, beta=10)
out1 = qfm(inputs)
print(out1)
qmeas = layers.QMeasureClassifEig(dim_x=8, dim_y=3, num_eig=0)
out2 = qmeas(out1)
print(out2)
dmr = layers.DensityMatrixRegression()
out3 = dmr(out2)
print(out3)

out3 = layers.CrossProduct()([out1, out2])
print(out3)
out4 = layers.DensityMatrix2Dist()(out2)
print(out4)