MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _counts_summary

Function _counts_summary

tensorflow/python/debug/cli/tensor_format.py:503–533  ·  view source on GitHub ↗

Format values as a two-row table.

(counts, skip_zeros=True, total_count=None)

Source from the content-addressed store, hash-verified

501 """
502
503 def _counts_summary(counts, skip_zeros=True, total_count=None):
504 """Format values as a two-row table."""
505 if skip_zeros:
506 counts = [(count_key, count_val) for count_key, count_val in counts
507 if count_val]
508 max_common_len = 0
509 for count_key, count_val in counts:
510 count_val_str = str(count_val)
511 common_len = max(len(count_key) + 1, len(count_val_str) + 1)
512 max_common_len = max(common_len, max_common_len)
513
514 key_line = debugger_cli_common.RichLine("|")
515 val_line = debugger_cli_common.RichLine("|")
516 for count_key, count_val in counts:
517 count_val_str = str(count_val)
518 key_line += _pad_string_to_length(count_key, max_common_len)
519 val_line += _pad_string_to_length(count_val_str, max_common_len)
520 key_line += " |"
521 val_line += " |"
522
523 if total_count is not None:
524 total_key_str = "total"
525 total_val_str = str(total_count)
526 max_common_len = max(len(total_key_str) + 1, len(total_val_str))
527 total_key_str = _pad_string_to_length(total_key_str, max_common_len)
528 total_val_str = _pad_string_to_length(total_val_str, max_common_len)
529 key_line += total_key_str + " |"
530 val_line += total_val_str + " |"
531
532 return debugger_cli_common.rich_text_lines_from_rich_line_list(
533 [key_line, val_line])
534
535 if not isinstance(tensor, np.ndarray) or not np.size(tensor):
536 return debugger_cli_common.RichTextLines([

Callers 1

numeric_summaryFunction · 0.85

Calls 2

_pad_string_to_lengthFunction · 0.85
maxFunction · 0.50

Tested by

no test coverage detected