Skip to content

Hparams: Set interval domain fields for float summary hparams. #6574

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

Merged
merged 3 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions tensorboard/plugins/hparams/backend_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,23 @@ def _compute_hparam_info_from_values(self, name, values):
return None

if result.type == api_pb2.DATA_TYPE_STRING:
distinct_values = set(
distinct_string_values = set(
_protobuf_value_to_string(v)
for v in values
if _can_be_converted_to_string(v)
)
result.domain_discrete.extend(distinct_values)
result.domain_discrete.extend(distinct_string_values)

if result.type == api_pb2.DATA_TYPE_BOOL:
result.domain_discrete.extend([True, False])

if result.type == api_pb2.DATA_TYPE_FLOAT64:
# Always uses interval domain type for numeric hparam values.
distinct_float_values = sorted([v.number_value for v in values])
if distinct_float_values:
result.domain_interval.min_value = distinct_float_values[0]
result.domain_interval.max_value = distinct_float_values[-1]

return result

def _experiment_from_data_provider_hparams(
Expand Down
8 changes: 8 additions & 0 deletions tensorboard/plugins/hparams/backend_context_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,18 @@ def test_experiment_with_session_tags(self):
hparam_infos: {
name: 'batch_size'
type: DATA_TYPE_FLOAT64
domain_interval {
min_value: 100.0
max_value: 300.0
}
},
hparam_infos: {
name: 'lr'
type: DATA_TYPE_FLOAT64
domain_interval {
min_value: 0.01
max_value: 0.05
}
},
hparam_infos: {
name: 'model_type'
Expand Down