code: def get_train(self):
      adj_mat = self.adj_mat
  
      mat_mask = 1.0 * (adj_mat > 0)
  
      _embeddings = tf.Variable(
          tf.contrib.layers.xavier_initializer()(
              [self.node_size, self.rep_size]
          ),
          dtype=tf.float32,
          name="embeddings",
      )
  
      Adj = tf.placeholder(
          tf.float32, [self.node_size, self.node_size], name="adj_mat"
      )
      AdjMask = tf.placeholder(
          tf.float32, [self.node_size, self.node_size], name="adj_mask"
      )
  
      cost = tf.reduce_sum(
          tf.square(
              Adj
              - tf.matmul(_embeddings, tf.transpose(_embeddings))
              * AdjMask
          )
      ) + self.lamb * tf.reduce_sum(tf.square(_embeddings))
  
      optimizer = tf.train.AdamOptimizer(self.lr)
      train_op = optimizer.minimize(cost)
  
      init = tf.global_variables_initializer()
      self.sess.run(init)
  
      print("total iter: %i" % self.max_iter)
      for step in range(self.max_iter):
          self.sess.run(
              train_op, feed_dict={Adj: adj_mat, AdjMask: mat_mask}
          )
          if step % 50 == 0:
              print(
                  "step %i: cost: %g"
                  % (
                      step,
                      self.sess.run(
                          cost,
                          feed_dict={Adj: adj_mat, AdjMask: mat_mask},
                      ),
                  )
              )
      return self.sess.run(_embeddings)
  
file_path: OpenNE/src/openne/gf.py
imports: from __future__ import print_function
  import numpy
  import tensorflow
  import networkx
label_desc: Use image node_id 3 for calling the GraphFactorization obj's underlying member method code with example usage: obj.get_train() and returns: self