question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Design a public Python API for the hparams plugin

See original GitHub issue

To use the hparams dashboard, users currently have to manually construct hparams-specific protocol buffers and send them to file writers (see the tutorial notebook for an example; it takes a few dozen lines of Python code). The protobuf bindings are not particularly idiomatic Python, and are less than pleasant to use. We should investigate possible simplifications to this API.

For example, we could streamline the construction of the ListValues for the discrete domains by allowing the user to pass Python lists, and we can also infer the data types from the types of the elements of the domain* (which also lets us require that the list is homogeneously typed):

def create_experiment_summary():
  api = hparams_summary  # for brevity
  hparams = [
      api.hparam("num_units", domain=api.discrete([16, 32])),
      api.hparam("dropout_rate", domain=api.interval(min=0.1, max=0.2)),
      api.hparam("optimizer", domain=api.discrete(["adam", "sgd"])),
  ]
  metrics = [
      api.metric("accuracy"),
      api.metric("xent", display_name="cross-entropy"),
  ]
  experiment = api.experiment(hparams=hparams, metrics=metrics)
  experiment.write(logdir=os.path.join("logs", "hparam_tuning"))

This is just a sketch, but it’s already three times shorter than the current demo without (imho) any loss of utility.

* It’s fine to prohibit empty domains here. If a hyperparameter has empty domain, then the whole hyperparameter space is empty, so there can be no runs; thus, allowing empty domains is not actually useful.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
wchargincommented, Jul 19, 2019

@moritzmeister: Long delay, I know, but: I’ve just added a trial_id kwarg to KerasCallback, hparams, and hparams_pb, as requested. The new forms are in latest nightly; see #2440/#2442.

I’m going to close this issue, since its original purpose has been completed and I don’t have any more planned changes in the works. Please feel free to open new issues for any further requests or feedback!

2reactions
wchargincommented, May 1, 2019

A few people have expressed confusion about the term “session” as used by the current hparams API. In TensorFlow 1.x, tf.Session is a core piece of technical infrastructure for evaluating graphs. In the hparams API, a “session” is a single run of the model (training plus validation) with one set of hyperparameter values, but in TensorFlow 1.x this may correspond to many sess.run() calls, and in TensorFlow 2.x there are no sessions at all. The two notions of “session” are roughly unrelated.

I propose omitting “session” from new API symbols where feasible, and using “trial” instead. This is consistent with Vizier’s usage—from §1.2 of the Vizier paper,

A Trial is a list of parameter values, x, that will lead to a single evaluation of f(x).

—and, I think, also suggests the correct meaning.

“Session groups” would most literally become “trial groups”, though this name doesn’t make it obvious that these are specifically groups of trials with the same hyperparameters (nor did “session groups”). Rather than just using this literal replacement, we should try to convey the actual meaning: e.g., instead of asking for a “session group name”, ask for a “hparams key”.

Even better, though, I think that we can avoid asking for session group names at all in the common case. Rather than letting the session group name default to the session name, we should let it default to something like sha256(str(hparams)). This satisfies the intended behavior of session groups partitioning the trial space by hyperparameter values, without requiring any additional user input.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the tensorboard.plugins.hparams.api_pb2 function ...
To help you get started, we've selected a few tensorboard.plugins.hparams.api_pb2 examples, based on popular ways it is used in public projects.
Read more >
Hyperparameter Tuning with the HParams Dashboard
Start runs and log them all under one parent directory; Visualize the results in TensorBoard's HParams dashboard. Note: The HParams summary APIs ......
Read more >
The complete guide to ML model visualization with Tensorboard
Let's create a function taking advantage of `matplotlib` – python visualization library -, to ... From TensorBoard plugins, let's import hparam' api module....
Read more >
hparams - PyPI
Extensible and Fault-Tolerant Hyperparameter Management. HParams is a thoughtful approach to configuration management for machine learning projects.
Read more >
Tensorflow Hparam replacement - Stack Overflow
In TF 2.0 there is a new API tensorboard.plugins.hparams.api that includes a class HParam. Usage of the new API is described in this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found