code: def learn(self, train_set):
      # placeholders
      C = tf.placeholder(tf.float32, shape=[None, self.c_dim], name="C")
      X_ = tf.placeholder(
          tf.float32, shape=[None, self.c_dim], name="X_"
      )
      Zik = tf.placeholder(tf.float32, shape=[None, self.k], name="Zik")
      Tk = tf.placeholder(tf.float32, shape=[None, self.k], name="Tk")
      E = tf.placeholder(
          tf.float32, shape=[None, self.k], name="E"
      )  # matrix of accepted samples epsilon, epsilon ~ pi(epsilon)
  
      # Sample Gamma variables using the Reparameterized Acceptance-Rejection approach
      alpha, beta = self.inference_net(C)
      E_ = self.sample_pi(alpha + self.B, beta)
      z_tld = self.G(E, alpha + self.B, beta)
      # getting the right z, this step is necessary when alpha<1.0
      U_ = self.shape_augmentation(alpha, self.B)
      z = U_ * z_tld
  
      # Generating
      X_g = self.generative_net(z)
  
      # preparing optimization
      loss = self.loss(C, X_g, X_, alpha, beta, z_tld, E, Zik, Tk)
      # train = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(loss)
      train = tf.train.RMSPropOptimizer(
          learning_rate=self.learning_rate
      ).minimize(loss)
  
      # Initialization
      init = tf.global_variables_initializer()
  
      # Learning
      self.sess.run(init)
  
      # Train the collaborative part
      resPF = self.pf_(
          self.cf_data,
          k=self.k,
          max_iter=1,
          init_params=self.init_params,
      )
  
      for epoch in range(self.n_epoch):
          for idx in train_set.item_iter(
              self.batch_size, shuffle=False
          ):
              batch_C = self.aux_data[idx].A
              EE = self.sess.run(E_, feed_dict={C: batch_C})
              z_c = self.sess.run(X_g, feed_dict={C: batch_C, E: EE})
              feed_dict = {
                  C: batch_C,
                  X_: z_c,
                  E: EE,
                  Zik: resPF["Zik"][idx],
                  Tk: resPF["Tk"][0 : len(idx)],
              }
              _, l = self.sess.run([train, loss], feed_dict=feed_dict)
              del (EE, z_c)
          for idx in train_set.item_iter(
              2 * self.batch_size, shuffle=False
          ):
              batch_C = self.aux_data[idx].A
              self.Ls[idx], self.Lr[idx] = self.sess.run(
                  [alpha, beta], feed_dict={C: batch_C}
              )
          print("epoch %i, Train Loss: %f" % (epoch, l))
          resPF = self.pf_(
              self.cf_data,
              k=self.k,
              max_iter=1,
              init_params={
                  "G_s": resPF["G_s"],
                  "G_r": resPF["G_r"],
                  "L_s": self.Ls,
                  "L_r": self.Lr,
              },
          )
      self.Gs = resPF["G_s"]
      self.Gr = resPF["G_r"]
      print("learning done successfully")
      # End of traning
  
      return self
  
file_path: cornac/cornac/models/pcrl/pcrl.py
imports: import numpy
  import scipy.sparse
  import scipy
  import tensorflow
label_desc: Use image node_id 15 for calling the PCRL_ obj's underlying member method code with example usage: obj.learn(train_set) and returns: self