Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

histogram: set v3 as default #5415

Merged
merged 4 commits into from Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions tensorboard/plugins/histogram/summary.py
Expand Up @@ -36,12 +36,12 @@


# Export V2 versions.
histogram_v2 = summary_v2.histogram_v2

# Export the default versions.
histogram = summary_v2.histogram
histogram_pb = summary_v2.histogram_pb

# Export V3 versions.
histogram_v3 = summary_v2.histogram_v3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this one line for now, so that anyone who was testing this out internally won't be broken by this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.



def _buckets(data, bucket_count=None):
"""Create a TensorFlow op to group data into histogram buckets.
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/plugins/histogram/summary_test.py
Expand Up @@ -240,7 +240,7 @@ def write_histogram_event(self, *args, **kwargs):
writer.close()

def call_histogram_op(self, *args, **kwargs):
summary.histogram(*args, **kwargs)
summary.histogram_v2(*args, **kwargs)

def test_scoped_tag(self):
with tf.name_scope("scope"):
Expand Down Expand Up @@ -306,7 +306,7 @@ def graph_fn():

class SummaryV3OpTest(SummaryV2OpTest, tf.test.TestCase):
def call_histogram_op(self, *args, **kwargs):
summary.histogram_v3(*args, **kwargs)
summary.histogram(*args, **kwargs)

def test_singleton_input(self):
pb = self.histogram("twelve", [12])
Expand Down
6 changes: 5 additions & 1 deletion tensorboard/plugins/histogram/summary_v2.py
Expand Up @@ -46,7 +46,7 @@
DEFAULT_BUCKET_COUNT = 30


def histogram(name, data, step=None, buckets=None, description=None):
def histogram_v2(name, data, step=None, buckets=None, description=None):
"""Write a histogram summary.

See also `tf.summary.scalar`, `tf.summary.SummaryWriter`.
Expand Down Expand Up @@ -507,3 +507,7 @@ def when_single_value():
)

return tf.cond(is_empty, when_empty, when_nonempty)


# Set V3 as default.
histogram = histogram_v3
16 changes: 10 additions & 6 deletions tensorboard/plugins/metrics/metrics_plugin_test.py
Expand Up @@ -420,6 +420,14 @@ def test_time_series_histogram(self):
)
clean_response = self._clean_time_series_responses(response)

# By default 30 bins will be generated.
bins_zero = [{"min": 0, "max": 0, "count": 0}] * 29 + [
{"min": 0, "max": 0, "count": 1.0}
]
bins_ten = [{"min": 10, "max": 10, "count": 0}] * 29 + [
{"min": 10, "max": 10, "count": 1.0}
]

self.assertEqual(
[
{
Expand All @@ -431,16 +439,12 @@ def test_time_series_histogram(self):
{
"wallTime": "<wall_time>",
"step": 0,
"bins": [
{"min": -0.5, "max": 0.5, "count": 1.0}
],
"bins": bins_zero,
},
{
"wallTime": "<wall_time>",
"step": 1,
"bins": [
{"min": 9.5, "max": 10.5, "count": 1.0}
],
"bins": bins_ten,
},
]
},
Expand Down