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 )
def __init__(self, fm_x, fm_y, dim_x, dim_y): 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)
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()
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
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)