Search code examples
pythonpytorchtensorboard

PyTorch Tensorboard not as described in documentation


I'm using PyTorch's ùtils.tensorboard.writer to log training of an RNN. For the àdd_hparams() function the Docs say:

Params:

  • hparam_dict (dict) – Each key-value pair in the dictionary is the name of the hyper parameter and it’s corresponding value. The type of the value can be one of bool, string, float, int, or None.
  • metric_dict (dict) – Each key-value pair in the dictionary is the name of the metric and it’s corresponding value. Note that the key used here should be unique in the tensorboard record. Otherwise the value you added by add_scalar will be displayed in hparam plugin. In most cases, this is unwanted.
  • hparam_domain_discrete – (Optional[Dict[str, List[Any]]]) A dictionary that contains names of the hyperparameters and all discrete values they can hold
  • run_name (str) – Name of the run, to be included as part of the logdir. If unspecified, will use current timestamp.

Source: https://pytorch.org/docs/master/tensorboard.html

But when I try to use the run_name parameter, I get the error

TypeError: add_hparams() got an unexpected keyword argument 'run_name'

So I looked up the writer.py file I imported and found the cause to be the add_hparams() function itself:

def add_hparams(self, hparam_dict, metric_dict):

I checked my installation of PyTorch, but it's up to date. Is this some sort of nightly feature, if so, how can I download the nightly version of torch?


Solution

  • The docs you linked to are the ones from the current master branch of PyTorch. So yes, it is a nightly feature. The docs of the stable version (1.6) do not mention add_hparams.

    You can get the command to download PyTorch nightly here by selecting Preview (Nightly) instead of Stable.