Skip to content

Commit cc6e294

Browse files
authored
Hparams: fix the bug where the last hparam was discarded when there is no limit (#6584)
Bug fixed by this PR: Currently when there is no limit, `_sort_and_reduce_to_hparams_limit()` truncates the last value. Corresponding unit test is wrong as well. 🤦 Googlers, see internal test at: cl/563163418 #hparams
1 parent 6fac09a commit cc6e294

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

tensorboard/plugins/hparams/backend_context.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,8 @@ def _sort_and_reduce_to_hparams_limit(experiment, hparams_limit=None):
599599
None. `experiment` proto will be modified in place.
600600
"""
601601
if not hparams_limit:
602-
hparams_limit = -1
602+
# If limit is unset or zero, returns all hparams.
603+
hparams_limit = len(experiment.hparam_infos)
603604

604605
# Prioritizes returning HParamInfo protos with `differed` values.
605606
limited_hparam_infos = sorted(

tensorboard/plugins/hparams/backend_context_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,11 @@ def test_experiment_from_tags_sorts_differed_hparams_first(self):
11741174
type: DATA_TYPE_FLOAT64
11751175
differs: false
11761176
}
1177+
hparam_infos: {
1178+
name: 'use_batch_norm'
1179+
type: DATA_TYPE_BOOL
1180+
differs: false
1181+
}
11771182
"""
11781183
actual_exp = self._experiment_from_metadata(
11791184
include_metrics=False, hparams_limit=None

0 commit comments

Comments
 (0)