Pytorch-lightning: How to remove `v_num` from the progress bar ?

Created on 24 Apr 2020  ·  15Comments  ·  Source: PyTorchLightning/pytorch-lightning

Version: 0.7.3

The v_num is automatically added to progress_bar when some logger is used
It is not much a problem for tensorboard when v_num is just a simple number
But v_num for mlfow takes a lot of space

Traning step

def training_step(self, batch, batch_nb):
    ....
    log = { "trn_loss": 0.1, "lr": 0.001 }
    return {"loss": loss, "log": log, "progress_bar": log}

Progress bar when using with mlflow logger

 [00:33<00:46, 1.62s/it, loss=0.740, lr=8e-6, trn_loss=0.659, v_num=18_28bc973b1f0e42e8b4d664d1ef7812f6]

Also, loss is automatically added to progress_bar

Logger documentation good first issue help wanted question

Most helpful comment

Side question: is the meaning of v_num documented anywhere in the introduction guide? It looks very mysterious to me until I read this post.

All 15 comments

loss and trn_loss are the same. you’re duplicating work.

maybe we can show only the last k letters for other exps

It may be a good default to show loss and v_num in progress bar when no progress_bar property in the return dict.
But here I explicitly ask to show only my trn_loss and lr (whatever they are). Why does package add loss and v_num ?

normally we run many (hundreds) of experiments to find a good set of hyperparams or a model that works for our task. as such, it’s very useful to know which experiment version you are running - v_num (experiment version number)

Thanks a lot @williamFalcon for the explanation.

maybe we can show only the last k letters for other exps

That should work.

Side question: is the meaning of v_num documented anywhere in the introduction guide? It looks very mysterious to me until I read this post.

@DKandrew mind share your proposal how would you describe in a PR?

@Borda Do you mean where to introduce v_num? I think a good place would be https://pytorch-lightning.readthedocs.io/en/latest/introduction_guide.html the "Train on CPU" section. That is the first time when we (beginner) encounter the progress bar.

Little bit of a hack but you can remove it manually by adding the following method in your lightning module:

def get_progress_bar_dict(self):
    tqdm_dict = super().get_progress_bar_dict()
    if 'v_num' in tqdm_dict:
        del tqdm_dict['v_num']
    return tqdm_dict

I also had no idea what v_num was until I read William's comment above.

@Borda Would renaming it to version be a solution?

Also, if it comes from the logger's version attribute then that's another reason to rename it (from v_num to version) since that isn't necessarily a number.

I created a PR here #2594 that truncates the long version numbers to 3 digits and also added docs how to override the defaults.
What @radao describes as a hack I would say is actually the recommended way. And it is not a hack because like any other hook in the LightningModule, you are free to override anything you want. For example, to drop the v_num completely, you would do

def get_progress_bar_dict(self):
    tqdm_dict = super().get_progress_bar_dict()
    tqdm_dict.pop("v_num", None)
    return tqdm_dict

The same approach can be used to rename it to "version" @nagyrajmund

Which length (num characters) is acceptable to truncate to?

  • 3 (currently)
  • ...
  • 7 (same length as git commit)
  • any other suggestions?

I think truncating to 3 is appropriate for both use cases (i.e. strings and simple numbers).

What is v_num meaning?

@xujiaze13 v_num is the version number of the experiment. Depending on the logger, this can be a simple counter that increases everytime you run the trainer. For other loggers, they have alphanumeric identifiers which can be quite long and fill up much of the tqdm progress bar, leaving no room for the important metrics to monitor.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anthonytec2 picture anthonytec2  ·  3Comments

williamFalcon picture williamFalcon  ·  3Comments

iakremnev picture iakremnev  ·  3Comments

Vichoko picture Vichoko  ·  3Comments

as754770178 picture as754770178  ·  3Comments