code: def log(self, key, val, step_num):
          
          try:
              ph, summ = self.summaries[key]
          except KeyError:
              # if we haven't defined a variable for this key, define one
              with self.g.as_default():
                  ph = tf.placeholder(tf.float32, (), name=key)  # scalar
                  summ = tf.scalar_summary(key, ph)
              self.summaries[key] = (ph, summ)
  
          summary_str = self.sess.run(summ, {ph: val})
          self.summ_writer.add_summary(summary_str, step_num)
          return val
docs: Directly log a scalar value to the event file.
  
          :param string key: a name for the value
          :param val: a float
          :param step_num: the iteration number at which this value was logged