victoresque / pytorch-template

PyTorch deep learning projects made easy.
MIT License
4.7k stars 1.08k forks source link

Proposal regarding "within epoch progress bar" #29

Closed borgesa closed 5 years ago

borgesa commented 5 years ago

Fast scrolling 'epoch text' drowning warnings

I support using the current usage of warnings, but they tend to drown quickly when the "Train epoch"-status rolls across the screen, blazing fast.

I guess most real projects (i.e., not the MNIST example) will most of the time will have slower updates, but I think it to some degree still applies.

Consider putting info into 'tqdm'?

I thought it could be nice to use tqdm for this "within epoch status". The tqdm progress bar description can be updated during training, like this:

epoch_iterator = tqdm(range(1, 5000))
for i in epoch_iterator:
    if i % 500 == 0:
        print("\nSomething hapened, so a message is printed. \n More text.\n")
    time.sleep(0.001)

    my_loss = 42
    epoch_iterator.set_description(f"Value: {i}, loss = {my_loss}")

The above does not behave perfectly (can hopefully be fixed), but I hope you get my point.

SunQpark commented 5 years ago

I like the tqdm personally, but I think we should be more careful adding it to this project. Some people may not like to use tqdm for reasons like it does not look good when output is saved into text file, or the progress bar breaks when terminal window size is changed. I placed it to test.py since that script is simple enough to remove tqdm without being annoyed. If we decide to add it onto the main code, possible solution would be something like in keras, where tqdm progress bar appears or not according to the verbosity option.