Esempio n. 1
0
 def AddHistogram(
     self,
     tag,
     wall_time=0,
     step=0,
     hmin=1,
     hmax=2,
     hnum=3,
     hsum=4,
     hsum_squares=5,
     hbucket_limit=None,
     hbucket=None,
 ):
     histo = summary_pb2.HistogramProto(
         min=hmin,
         max=hmax,
         num=hnum,
         sum=hsum,
         sum_squares=hsum_squares,
         bucket_limit=hbucket_limit,
         bucket=hbucket,
     )
     event = event_pb2.Event(
         wall_time=wall_time,
         step=step,
         summary=summary_pb2.Summary(
             value=[summary_pb2.Summary.Value(tag=tag, histo=histo)]),
     )
     self.AddEvent(event)
Esempio n. 2
0
  def _WriteScalarSummaries(self, data, subdirs=('',)):
    # Writes data to a tempfile in subdirs, and returns generator for the data.
    # If subdirs is given, writes data identically to all subdirectories.
    for subdir_ in subdirs:
      subdir = os.path.join(self.logdir, subdir_)
      self._MakeDirectoryIfNotExists(subdir)

      with test_util.FileWriterCache.get(subdir) as sw:
        for datum in data:
          summary = summary_pb2.Summary()
          if 'simple_value' in datum:
            summary.value.add(tag=datum['tag'],
                              simple_value=datum['simple_value'])
            sw.add_summary(summary, global_step=datum['step'])
          elif 'histo' in datum:
            summary.value.add(tag=datum['tag'],
                              histo=summary_pb2.HistogramProto())
            sw.add_summary(summary, global_step=datum['step'])
          elif 'session_log' in datum:
            sw.add_session_log(datum['session_log'], global_step=datum['step'])