Skip to content

Commit

Permalink
Hparams: fix the bug where the last hparam was discarded when there i…
Browse files Browse the repository at this point in the history
…s 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
  • Loading branch information
yatbear authored Sep 18, 2023
1 parent 6fac09a commit cc6e294
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tensorboard/plugins/hparams/backend_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,8 @@ def _sort_and_reduce_to_hparams_limit(experiment, hparams_limit=None):
None. `experiment` proto will be modified in place.
"""
if not hparams_limit:
hparams_limit = -1
# If limit is unset or zero, returns all hparams.
hparams_limit = len(experiment.hparam_infos)

# Prioritizes returning HParamInfo protos with `differed` values.
limited_hparam_infos = sorted(
Expand Down
5 changes: 5 additions & 0 deletions tensorboard/plugins/hparams/backend_context_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,11 @@ def test_experiment_from_tags_sorts_differed_hparams_first(self):
type: DATA_TYPE_FLOAT64
differs: false
}
hparam_infos: {
name: 'use_batch_norm'
type: DATA_TYPE_BOOL
differs: false
}
"""
actual_exp = self._experiment_from_metadata(
include_metrics=False, hparams_limit=None
Expand Down

0 comments on commit cc6e294

Please sign in to comment.