Ejemplo 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)
Ejemplo n.º 2
0
 def __init__(self, fm_x, fm_y, dim_x, dim_y):
     #print("**********init****************")
     super(QMClassifier, 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.dm2dist = layers.DensityMatrix2Dist()
     self.cp1 = layers.CrossProduct()
     self.cp2 = layers.CrossProduct()
     self.num_samples = tf.Variable(
         initial_value=0.,
         trainable=False     
         )
Ejemplo n.º 3
0
 def __init__(self, fm_x, dim_x):
     super(QMDensity, self).__init__()
     self.fm_x = fm_x
     self.dim_x = dim_x
     self.qmd = layers.QMeasureDensity(dim_x)
     self.cp = layers.CrossProduct()
     self.num_samples = tf.Variable(initial_value=0., trainable=False)
Ejemplo n.º 4
0
 def __init__(self, fm_x, fm_y_1, fm_y_2, fm_y, dim_x, dim_y_1, dim_y_2, dim_y):
     super(QMFindingsClassifier, self).__init__()
     #print("Empieza el init")
     self.fm_x = fm_x
     self.fm_y_1 = fm_y_1
     self.fm_y_2 = fm_y_2
     self.fm_y = fm_y
     self.qm1 = layers.QMeasureClassif(dim_x=dim_x, dim_y=dim_y_1)
     self.qm2 = layers.QMeasureClassif(dim_x=dim_x, dim_y=dim_y_2)
     
     self.qm = layers.QMeasureClassif(dim_x=4, dim_y=dim_y)
     
     self.dm2dist_1 = layers.DensityMatrix2Dist()
     
     self.dm2dist = layers.DensityMatrix2Dist()
     
     self.cp1 = layers.CrossProduct()
     self.cp2 = layers.CrossProduct()
     
     self.cp3 = layers.CrossProduct()
     self.cp4 = layers.CrossProduct()
     
     self.cp5 = layers.CrossProduct()
     self.cp6 = layers.CrossProduct()
     self.cp7 = layers.CrossProduct()
     
     self.num_samples = tf.Variable(
         initial_value=0.,
         trainable=False     
         )
Ejemplo n.º 5
0
 def __init__(self, fm_x, dim_x, num_classes=2):
     super(QMKDClassifier, self).__init__()
     self.fm_x = fm_x
     self.dim_x = dim_x
     self.num_classes = num_classes
     self.qmd = []
     for _ in range(num_classes):
         self.qmd.append(layers.QMeasureDensity(dim_x))
     self.cp = layers.CrossProduct()
     self.num_samples = tf.Variable(initial_value=tf.zeros((num_classes, )),
                                    trainable=False)
Ejemplo n.º 6
0
 def __init__(self, input_dim, dim_x, dim_y_1, dim_y_2, dim_y, num_eig_1=0, num_eig_2=0, num_eig=0, gamma=1, random_state=None):
     #print("**********init****************")
     super(QMFindingsClassifierSGD, self).__init__()
     self.fm_x = layers.QFeatureMapRFF(
         input_dim=input_dim,
         dim=dim_x, gamma=gamma, random_state=random_state)
     self.qm_1 = layers.QMeasureClassifEig(dim_x=dim_x, dim_y=dim_y_1, num_eig=num_eig_1)
     self.qm_2 = layers.QMeasureClassifEig(dim_x=dim_x, dim_y=dim_y_2, num_eig=num_eig_2)
     self.qm = layers.QMeasureClassifEig(dim_x=4, dim_y=dim_y, num_eig=num_eig)
     self.dm2dist_1 = layers.DensityMatrix2Dist()
     self.dm2dist = layers.DensityMatrix2Dist()
     self.dim_x = dim_x
     self.dim_y = dim_y
     self.dim_y_1 = dim_y_1
     self.dim_y_2 = dim_y_2
     self.gamma = gamma
     self.random_state = random_state
     
     self.cp = layers.CrossProduct()
Ejemplo n.º 7
0
 def __init__(self, input_dim, dim_x, num_classes, num_classes_1, num_classes_2, num_eig_1=0, num_eig_2=0, num_eig=0, gamma=1, random_state=None):
     super(QMKDFindingsClassifierSGD, self).__init__()
     self.fm_x = layers.QFeatureMapRFF(
         input_dim=input_dim,
         dim=dim_x, gamma=gamma, random_state=random_state)
     self.dim_x = dim_x
     self.num_classes_1 = num_classes_1
     self.num_classes_2 = num_classes_2
     self.num_classes = num_classes
     self.qmd_1 = []
     for _ in range(num_classes_1):
         self.qmd_1.append(layers.QMeasureDensityEig(dim_x, num_eig_1))
     self.qmd_2 = []
     for _ in range(num_classes_2):
         self.qmd_2.append(layers.QMeasureDensityEig(dim_x, num_eig_2))    
     self.qmd = []
     for _ in range(num_classes):
         self.qmd.append(layers.QMeasureDensityEig(4, num_eig))
     self.gamma = gamma
     self.cp = layers.CrossProduct()
     self.random_state = random_state
Ejemplo n.º 8
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)