當前位置: 首頁>>代碼示例>>Python>>正文


Python tensorflow.HistogramProto方法代碼示例

本文整理匯總了Python中tensorflow.HistogramProto方法的典型用法代碼示例。如果您正苦於以下問題:Python tensorflow.HistogramProto方法的具體用法?Python tensorflow.HistogramProto怎麽用?Python tensorflow.HistogramProto使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow的用法示例。


在下文中一共展示了tensorflow.HistogramProto方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: AddHistogram

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import HistogramProto [as 別名]
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 = tf.HistogramProto(min=hmin,
                              max=hmax,
                              num=hnum,
                              sum=hsum,
                              sum_squares=hsum_squares,
                              bucket_limit=hbucket_limit,
                              bucket=hbucket)
    event = tf.summary.Event(
        wall_time=wall_time,
        step=step,
        summary=tf.Summary(value=[tf.Summary.Value(
            tag=tag, histo=histo)]))
    self.AddEvent(event) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:26,代碼來源:event_accumulator_test.py

示例2: _MakeHistogram

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import HistogramProto [as 別名]
def _MakeHistogram(values):
  """Convert values into a histogram proto using logic from histogram.cc."""
  limits = _MakeHistogramBuckets()
  counts = [0] * len(limits)
  for v in values:
    idx = bisect.bisect_left(limits, v)
    counts[idx] += 1

  limit_counts = [(limits[i], counts[i]) for i in xrange(len(limits))
                  if counts[i]]
  bucket_limit = [lc[0] for lc in limit_counts]
  bucket = [lc[1] for lc in limit_counts]
  sum_sq = sum(v * v for v in values)
  return tf.HistogramProto(min=min(values),
                           max=max(values),
                           num=len(values),
                           sum=sum(values),
                           sum_squares=sum_sq,
                           bucket_limit=bucket_limit,
                           bucket=bucket) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:22,代碼來源:generate_testdata.py

示例3: histo_summary

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import HistogramProto [as 別名]
def histo_summary(self, tag, values, step, bins=1000):
        # Create a histogram using numpy
        counts, bin_edges = np.histogram(values, bins=bins)

        # Fill the fields of the histogram proto
        hist = tf.HistogramProto()
        hist.min = float(np.min(values))
        hist.max = float(np.max(values))
        hist.num = int(np.prod(values.shape))
        hist.sum = float(np.sum(values))
        hist.sum_squares = float(np.sum(values ** 2))

        # Drop the start of the first bin
        bin_edges = bin_edges[1:]

        # Add bin edges and counts
        for edge in bin_edges:
            hist.bucket_limit.append(edge)
        for c in counts:
            hist.bucket.append(c)

        # Create and write Summary
        summary = tf.Summary(value=[tf.Summary.Value(tag=tag, histo=hist)])
        self.writer.add_summary(summary, step) 
開發者ID:vacancy,項目名稱:Jacinle,代碼行數:26,代碼來源:tb.py

示例4: log_histogram

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import HistogramProto [as 別名]
def log_histogram(self, tag, values, step = None, bins = 1000):
        if not step:
            step = self.step
        values = np.array(values)
        counts, bin_edges = np.histogram(values, bins=bins)
        hist = tf.HistogramProto()
        hist.min = float(np.min(values))
        hist.max = float(np.max(values))
        hist.num = int(np.prod(values.shape))
        hist.sum = float(np.sum(values))
        hist.sum_squares = float(np.sum(values**2))
        for edge in bin_edges:
            hist.bucket_limit.append(edge)
        for c in counts:
            hist.bucket.append(c)
            
        summary = tf.Summary(value=[tf.Summary.Value(tag=tag, histo=hist)])
        self.writer.add_summary(summary, step)
        self.writer.flush() 
開發者ID:thuml,項目名稱:Separate_to_Adapt,代碼行數:21,代碼來源:utilities.py

示例5: log_histogram

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import HistogramProto [as 別名]
def log_histogram(self, tag, values, bins=1000):
    """ https://gist.github.com/gyglim/1f8dfb1b5c82627ae3efcfbbadb9f514 """
    values = np.array(values)

    counts, bin_edges = np.histogram(values, bins=bins)

    hist = tf.HistogramProto()
    hist.min = float(np.min(values))
    hist.max = float(np.max(values))
    hist.num = int(np.prod(values.shape))
    hist.sum = float(np.sum(values))
    hist.sum_squares = float(np.sum(values**2))

    bin_edges = bin_edges[1:]

    for edge in bin_edges:
      hist.bucket_limit.append(edge)
    for c in counts:
      hist.bucket.append(c)

    summary = tf.Summary(value=[tf.Summary.Value(tag=tag, histo=hist)])
    self.writer.add_summary(summary, self._hparams.global_step)
    self.writer.flush() 
開發者ID:for-ai,項目名稱:rl,代碼行數:25,代碼來源:logger.py

示例6: histo_summary

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import HistogramProto [as 別名]
def histo_summary(self, tag, values, step, bins=1000):
        """Log a histogram of the tensor of values."""

        # Create a histogram using numpy
        counts, bin_edges = np.histogram(values, bins=bins)

        # Fill the fields of the histogram proto
        hist = tf.HistogramProto()
        hist.min = float(np.min(values))
        hist.max = float(np.max(values))
        hist.num = int(np.prod(values.shape))
        hist.sum = float(np.sum(values))
        hist.sum_squares = float(np.sum(values**2))

        # Drop the start of the first bin
        bin_edges = bin_edges[1:]

        # Add bin edges and counts
        for edge in bin_edges:
            hist.bucket_limit.append(edge)
        for c in counts:
            hist.bucket.append(c)

        # Create and write Summary
        summary = tf.Summary(value=[tf.Summary.Value(tag=tag, histo=hist)])
        self.writer.add_summary(summary, step)
        self.writer.flush() 
開發者ID:guoruoqian,項目名稱:cascade-rcnn_Pytorch,代碼行數:29,代碼來源:logger.py

示例7: histo_summary

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import HistogramProto [as 別名]
def histo_summary(self, tag, values, step, bins=1000):
        """Log a histogram of the tensor of values."""

        # Create a histogram using numpy
        counts, bin_edges = np.histogram(values, bins=bins)

        # Fill the fields of the histogram proto
        hist = tf.HistogramProto()
        hist.min = float(np.min(values))
        hist.max = float(np.max(values))
        hist.num = int(np.prod(values.shape))
        hist.sum = float(np.sum(values))
        hist.sum_squares = float(np.sum(values ** 2))

        # Drop the start of the first bin
        bin_edges = bin_edges[1:]

        # Add bin edges and counts
        for edge in bin_edges:
            hist.bucket_limit.append(edge)
        for c in counts:
            hist.bucket.append(c)

        # Create and write Summary
        summary = tf.Summary(value=[tf.Summary.Value(tag=tag, histo=hist)])
        self.writer.add_summary(summary, step)
        self.writer.flush() 
開發者ID:Mariewelt,項目名稱:OpenChem,代碼行數:29,代碼來源:logger.py

示例8: histo_summary

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import HistogramProto [as 別名]
def histo_summary(self, tag, values, step, bins=1000):
        """Log a histogram of the tensor of values."""
        # 直方圖信息 日誌
        # Create a histogram using numpy
        counts, bin_edges = np.histogram(values, bins=bins)

        # Fill the fields of the histogram proto
        hist = tf.HistogramProto()
        hist.min = float(np.min(values))
        hist.max = float(np.max(values))
        hist.num = int(np.prod(values.shape))
        hist.sum = float(np.sum(values))
        hist.sum_squares = float(np.sum(values ** 2))

        # Drop the start of the first bin
        bin_edges = bin_edges[1:]

        # Add bin edges and counts
        for edge in bin_edges:
            hist.bucket_limit.append(edge)
        for c in counts:
            hist.bucket.append(c)

        # Create and write Summary
        summary = tf.Summary(value=[tf.Summary.Value(tag=tag, histo=hist)])
        self.writer.add_summary(summary, step)
        self.writer.flush() 
開發者ID:MagicChuyi,項目名稱:SlowFast-Network-pytorch,代碼行數:29,代碼來源:TF_logger.py

示例9: histo_summary

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import HistogramProto [as 別名]
def histo_summary(self, tag, values, step, scope, bins=1000, ):
        """Log a histogram of the tensor of values."""
        counts, bin_edges = np.histogram(values, bins=bins)
        # Fill the fields of the histogram proto
        hist = tf.HistogramProto()
        hist.min = float(np.min(values))
        hist.max = float(np.max(values))
        hist.num = int(np.prod(values.shape))
        hist.sum = float(np.sum(values))
        hist.sum_squares = float(np.sum(values ** 2))

        # Drop the start of the first bin
        bin_edges = bin_edges[1:]

        # Add bin edges and counts
        for edge in bin_edges:
            hist.bucket_limit.append(edge)
        for c in counts:
            hist.bucket.append(c)

        # Create and write Summary
        summary = tf.Summary(value=[tf.Summary.Value(tag=os.path.join(scope, tag), histo=hist)])
        self.summary_writer.add_summary(summary, step)
        self.summary_writer.flush()

    # summarize tenorflow tenosrs or images or merged summary, but this requires tensorflow session run 
開發者ID:MrGemy95,項目名稱:visual-interaction-networks-pytorch,代碼行數:28,代碼來源:logger.py

示例10: log_histogram

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import HistogramProto [as 別名]
def log_histogram(self, tag, values, step, bins=1000):
        """Logs the histogram of a list/vector of values."""

        # Create histogram using numpy
        counts, bin_edges = np.histogram(values, bins=bins)

        # Fill fields of histogram proto
        hist = tf.HistogramProto()
        hist.min = float(np.min(values))
        hist.max = float(np.max(values))
        hist.num = int(np.prod(values.shape))
        hist.sum = float(np.sum(values))
        hist.sum_squares = float(np.sum(values**2))

        # Requires equal number as bins, where the first goes from -DBL_MAX to bin_edges[1]
        # See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/summary.proto#L30
        # Thus, we drop the start of the first bin
        bin_edges = bin_edges[1:]

        # Add bin edges and counts
        for edge in bin_edges:
            hist.bucket_limit.append(edge)
        for c in counts:
            hist.bucket.append(c)

        # Create and write Summary
        summary = tf.Summary(value=[tf.Summary.Value(tag=tag, histo=hist)])
        self.writer.add_summary(summary, step)
        self.writer.flush() 
開發者ID:akar43,項目名稱:lsm,代碼行數:31,代碼來源:tensorboard_logging.py

示例11: log_histogram

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import HistogramProto [as 別名]
def log_histogram(self, tag, values, step, bins=1000):
        """Logs the histogram of a list/vector of values."""
        # Convert to a numpy array
        values = np.array(values)

        # Create histogram using numpy
        counts, bin_edges = np.histogram(values, bins=bins)

        # Fill fields of histogram proto
        hist = tf.HistogramProto()
        hist.min = float(np.min(values))
        hist.max = float(np.max(values))
        hist.num = int(np.prod(values.shape))
        hist.sum = float(np.sum(values))
        hist.sum_squares = float(np.sum(values ** 2))

        # Requires equal number as bins, where the first goes from -DBL_MAX to bin_edges[1]
        # See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/summary.proto#L30
        # Thus, we drop the start of the first bin
        bin_edges = bin_edges[1:]

        # Add bin edges and counts
        for edge in bin_edges:
            hist.bucket_limit.append(edge)
        for c in counts:
            hist.bucket.append(c)

        # Create and write Summary
        summary = tf.Summary(value=[tf.Summary.Value(tag=tag, histo=hist)])
        self.writer.add_summary(summary, step)
        self.writer.flush() 
開發者ID:songyanho,項目名稱:Reinforcement-Learning-for-Self-Driving-Cars,代碼行數:33,代碼來源:cnn.py

示例12: histogram

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import HistogramProto [as 別名]
def histogram(self, tag, values, bins, step=None):
    """Saves histogram of values.

    Args:
      tag: str: label for this data
      values: ndarray: will be flattened by this routine
      bins: number of bins in histogram, or array of bins for onp.histogram
      step: int: training step
    """
    if step is None:
      step = self._step
    else:
      self._step = step
    values = onp.array(values)
    bins = onp.array(bins)
    values = onp.reshape(values, -1)
    counts, limits = onp.histogram(values, bins=bins)
    # boundary logic
    cum_counts = onp.cumsum(onp.greater(counts, 0, dtype=onp.int32))
    start, end = onp.searchsorted(
        cum_counts, [0, cum_counts[-1] - 1], side='right')
    start, end = int(start), int(end) + 1
    counts = (
        counts[start -
               1:end] if start > 0 else onp.concatenate([[0], counts[:end]]))
    limits = limits[start:end + 1]
    sum_sq = values.dot(values)
    histo = HistogramProto(
        min=values.min(),
        max=values.max(),
        num=len(values),
        sum=values.sum(),
        sum_squares=sum_sq,
        bucket_limit=limits.tolist(),
        bucket=counts.tolist())
    summary = Summary(value=[Summary.Value(tag=tag, histo=histo)])
    self.add_summary(summary, step) 
開發者ID:yyht,項目名稱:BERT,代碼行數:39,代碼來源:jaxboard.py


注:本文中的tensorflow.HistogramProto方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。