Exemple #1
0
 def __init__(self, input_dim, dim_x, num_eig=0, gamma=1, random_state=None):
     super(QMDensitySGD, self).__init__()
     self.fm_x = layers.QFeatureMapRFF(
         input_dim=input_dim,
         dim=dim_x, gamma=gamma, random_state=random_state)
     self.qmd = layers.QMeasureDensityEig(dim_x=dim_x, num_eig=num_eig)
     self.num_eig = num_eig
     self.dim_x = dim_x
     self.gamma = gamma
     self.random_state = random_state
Exemple #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
Exemple #3
0
 def __init__(self, input_dim, dim_x, num_classes, num_eig=0, gamma=1, random_state=None):
     super(QMKDClassifierSGD, 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 = num_classes
     self.qmd = []
     for _ in range(num_classes):
         self.qmd.append(layers.QMeasureDensityEig(dim_x, num_eig))
     self.gamma = gamma
     self.random_state = random_state
Exemple #4
0
 def __init__(self, input_dim, dim_x, dim_y, num_eig=0, gamma=1, random_state=None):
     #print("**********init****************")
     super(QMClassifierSGD, 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.dm2dist = layers.DensityMatrix2Dist()
     self.dim_x = dim_x
     self.dim_y = dim_y
     self.gamma = gamma
     self.random_state = random_state
Exemple #5
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()
Exemple #6
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
Exemple #7
0
import numpy as np
from qmc.tf import layers
from qmc.tf import models

data_x = tf.constant([[0., 0.], [
    0.,
    1,
], [
    1.,
    0,
], [
    1.,
    1,
]])
data_y = tf.constant([[0], [1], [1], [0]])
fm_x = layers.QFeatureMapRFF(input_dim=2, dim=10, gamma=4, random_state=10)
qmd = models.QMDensity(fm_x)
out = qmd(data_x)
print(out)
qmd.compile()
qmd.fit(data_x, data_y, epochs=1)
out = qmd(data_x)
print(out)

#fm_x = layers.QFeatureMapSmp(dim=2, beta=10)
fm_x = layers.QFeatureMapRFF(input_dim=2, dim=10, gamma=4, random_state=10)
fm_y = layers.QFeatureMapOneHot(num_classes=2)
#fm_y = lambda x: tf.squeeze(tf.keras.backend.one_hot(x, 2))
qmc = models.QMClassifier(fm_x, fm_y, dim_y=2)
out = qmc(data_x)
print(out)