model.py
def partial_train(self, batch, label):
    """Train model based on mini-batch of input data.

    Return cost of mini-batch.

    I should really seperate the below tricks into parameters, like number of times/pass
    and also the regulator threshold levels.
    """

    counter = 0

    label_one_hot = self.to_one_hot(label)

    '''
    for i in range(1):
      counter += 1
      _, vae_loss = self.sess.run((self.vae_opt, self.vae_loss),
                              feed_dict={self.batch: batch, self.x: self.x_vec, self.y: self.y_vec, self.r: self.r_vec, self.batch_label: label_one_hot})
    '''

    for i in range(16):
      counter += 1
      _, g_loss, vae_loss, g_accuracy = self.sess.run((self.g_opt, self.g_loss, self.vae_loss, self.g_loss_accuracy),
                              feed_dict={self.batch: batch, self.x: self.x_vec, self.y: self.y_vec, self.r: self.r_vec, self.batch_label: label_one_hot})
      if g_accuracy > 0.98:
        break

    # train classifier on only real mnist digits
    # _ = self.sess.run((self.d_opt_real), feed_dict={self.batch: batch, self.x: self.x_vec, self.y: self.y_vec, self.r: self.r_vec, self.batch_label: label_one_hot})

    # calculate accuracy before deciding whether to train discriminator
    d_loss, d_loss_real, d_loss_fake, d_real_accuracy, d_fake_accuracy = self.sess.run((self.d_loss, self.d_loss_real, self.d_loss_fake, self.d_loss_real_accuracy, self.d_loss_fake_accuracy),
                              feed_dict={self.batch: batch, self.x: self.x_vec, self.y: self.y_vec, self.r: self.r_vec, self.batch_label: label_one_hot})

    if d_fake_accuracy < 0.7 and g_accuracy > 0.6: # only train discriminiator if generator is good and d is behind.
      for i in range(8):
        counter += 1
        _, d_loss, d_loss_real, d_loss_fake, d_real_accuracy, d_fake_accuracy = self.sess.run((self.d_opt, self.d_loss, self.d_loss_real, self.d_loss_fake, self.d_loss_real_accuracy, self.d_loss_fake_accuracy),
                                feed_dict={self.batch: batch, self.x: self.x_vec, self.y: self.y_vec, self.r: self.r_vec, self.batch_label: label_one_hot})
        if d_fake_accuracy > 0.75:
          break
    elif d_real_accuracy < 0.6:
      for i in range(8):
        counter += 1
        _, d_real_accuracy = self.sess.run((self.d_opt_real, self.d_loss_real_accuracy), feed_dict={self.batch: batch, self.x: self.x_vec, self.y: self.y_vec, self.r: self.r_vec, self.batch_label: label_one_hot})
        if d_real_accuracy > 0.7:
          break

    return d_loss, g_loss, vae_loss, counter, d_real_accuracy, d_fake_accuracy, g_accuracy, d_loss_real, d_loss_fake
Train model based on mini-batch of input data.

    Return cost of mini-batch.

    I should really seperate the below tricks into parameters, like number of times/pass
    and also the regulator threshold levels.
    
Train model based on mini-batch of input data.
Return cost of mini-batch.

I should really seperate the below tricks into parameters, like number of times/pass
and also the regulator threshold levels.
Train model based on mini - batch of input data . Return cost of mini - batch . I should really seperate the below tricks into parameters like number of times / pass and also the regulator threshold levels .
def partial_train(self, batch, label):
    counter = 0
    label_one_hot = self.to_one_hot(label)
    for i in range(16):
      counter += 1
      _, g_loss, vae_loss, g_accuracy = self.sess.run((self.g_opt, self.g_loss, self.vae_loss, self.g_loss_accuracy),
                              feed_dict={self.batch: batch, self.x: self.x_vec, self.y: self.y_vec, self.r: self.r_vec, self.batch_label: label_one_hot})
      if g_accuracy > 0.98:
        break
    d_loss, d_loss_real, d_loss_fake, d_real_accuracy, d_fake_accuracy = self.sess.run((self.d_loss, self.d_loss_real, self.d_loss_fake, self.d_loss_real_accuracy, self.d_loss_fake_accuracy),
                              feed_dict={self.batch: batch, self.x: self.x_vec, self.y: self.y_vec, self.r: self.r_vec, self.batch_label: label_one_hot})
    if d_fake_accuracy < 0.7 and g_accuracy > 0.6: 
      for i in range(8):
        counter += 1
        _, d_loss, d_loss_real, d_loss_fake, d_real_accuracy, d_fake_accuracy = self.sess.run((self.d_opt, self.d_loss, self.d_loss_real, self.d_loss_fake, self.d_loss_real_accuracy, self.d_loss_fake_accuracy),
                                feed_dict={self.batch: batch, self.x: self.x_vec, self.y: self.y_vec, self.r: self.r_vec, self.batch_label: label_one_hot})
        if d_fake_accuracy > 0.75:
          break
    elif d_real_accuracy < 0.6:
      for i in range(8):
        counter += 1
        _, d_real_accuracy = self.sess.run((self.d_opt_real, self.d_loss_real_accuracy), feed_dict={self.batch: batch, self.x: self.x_vec, self.y: self.y_vec, self.r: self.r_vec, self.batch_label: label_one_hot})
        if d_real_accuracy > 0.7:
          break
    return d_loss, g_loss, vae_loss, counter, d_real_accuracy, d_fake_accuracy, g_accuracy, d_loss_real, d_loss_fake
def partial_train ( self , batch , label ) : counter = 0 label_one_hot = self . to_one_hot ( label ) '''
    for i in range(1):
      counter += 1
      _, vae_loss = self.sess.run((self.vae_opt, self.vae_loss),
                              feed_dict={self.batch: batch, self.x: self.x_vec, self.y: self.y_vec, self.r: self.r_vec, self.batch_label: label_one_hot})
    ''' for i in range ( 16 ) : counter += 1 _ , g_loss , vae_loss , g_accuracy = self . sess . run ( ( self . g_opt , self . g_loss , self . vae_loss , self . g_loss_accuracy ) , feed_dict = { self . batch : batch , self . x : self . x_vec , self . y : self . y_vec , self . r : self . r_vec , self . batch_label : label_one_hot } ) if g_accuracy > 0.98 : break d_loss , d_loss_real , d_loss_fake , d_real_accuracy , d_fake_accuracy = self . sess . run ( ( self . d_loss , self . d_loss_real , self . d_loss_fake , self . d_loss_real_accuracy , self . d_loss_fake_accuracy ) , feed_dict = { self . batch : batch , self . x : self . x_vec , self . y : self . y_vec , self . r : self . r_vec , self . batch_label : label_one_hot } ) if d_fake_accuracy < 0.7 and g_accuracy > 0.6 : for i in range ( 8 ) : counter += 1 _ , d_loss , d_loss_real , d_loss_fake , d_real_accuracy , d_fake_accuracy = self . sess . run ( ( self . d_opt , self . d_loss , self . d_loss_real , self . d_loss_fake , self . d_loss_real_accuracy , self . d_loss_fake_accuracy ) , feed_dict = { self . batch : batch , self . x : self . x_vec , self . y : self . y_vec , self . r : self . r_vec , self . batch_label : label_one_hot } ) if d_fake_accuracy > 0.75 : break elif d_real_accuracy < 0.6 : for i in range ( 8 ) : counter += 1 _ , d_real_accuracy = self . sess . run ( ( self . d_opt_real , self . d_loss_real_accuracy ) , feed_dict = { self . batch : batch , self . x : self . x_vec , self . y : self . y_vec , self . r : self . r_vec , self . batch_label : label_one_hot } ) if d_real_accuracy > 0.7 : break return d_loss , g_loss , vae_loss , counter , d_real_accuracy , d_fake_accuracy , g_accuracy , d_loss_real , d_loss_fake
Train model based on mini-batch of input data.
Train model based on mini - batch of input data .
"""Train model based on mini-batch of input data.

    Return cost of mini-batch.

    I should really seperate the below tricks into parameters, like number of times/pass
    and also the regulator threshold levels.
    """ '''
    for i in range(1):
      counter += 1
      _, vae_loss = self.sess.run((self.vae_opt, self.vae_loss),
                              feed_dict={self.batch: batch, self.x: self.x_vec, self.y: self.y_vec, self.r: self.r_vec, self.batch_label: label_one_hot})
    ''' # train classifier on only real mnist digits # _ = self.sess.run((self.d_opt_real), feed_dict={self.batch: batch, self.x: self.x_vec, self.y: self.y_vec, self.r: self.r_vec, self.batch_label: label_one_hot}) # calculate accuracy before deciding whether to train discriminator # only train discriminiator if generator is good and d is behind.
self
batch
label