Package: dlprog
dlprogDeep Learning ProgressA Python library for progress bars with the function of aggregating each iteration's value.It helps manage the loss of each epoch in deep learning or machine learning training.PyPIAPI ReferenceInstallationpipinstalldlprogGeneral UsageSetupfromdlprogimportProgressprog=Progress()Exampleimportrandomimporttimen_epochs=3n_iter=10prog.start(n_epochs=n_epochs,n_iter=n_iter,label='value')# Initialize start time and epoch.for_inrange(n_epochs):for_inrange(n_iter):time.sleep(0.1)value=random.random()prog.update(value)# Update progress bar and aggregate value.1/3: ######################################## 100% [00:00:01.06] value: 0.64755 
2/3: ######################################## 100% [00:00:01.05] value: 0.41097 
3/3: ######################################## 100% [00:00:01.06] value: 0.26648Get each epoch's value>>> prog.values
[0.6475490908029968, 0.4109736504929395, 0.26648041702649705]Callget_all_values()method to get all values of each iteration.
Andget_all_times()method to get all times of each iteration.In machine learning trainingSetup.train_progressfunction is a shortcut forProgressclass.
Return a progress bar that is suited for machine learning training.fromdlprogimporttrain_progressprog=train_progress()Example. Case of training a deep learning model with PyTorch.n_epochs=3n_iter=len(dataloader)prog.start(n_epochs=n_epochs,n_iter=n_iter)for_inrange(n_epochs):forx,labelindataloader:optimizer.zero_grad()y=model(x)loss=criterion(y,label)loss.backward()optimizer.step()prog.update(loss.item())Output1/3: ######################################## 100% [00:00:03.08] loss: 0.34099 
2/3: ######################################## 100% [00:00:03.12] loss: 0.15259 
3/3: ######################################## 100% [00:00:03.14] loss: 0.10684If you want to obtain weighted exact values considering batch size:prog.update(loss.item(),weight=len(x))Advanced usageAdvanced arguments, functions, etc.Also, seeAPI Referenceif you want to know more.leave_freqArgument that controls the frequency of leaving the progress bar.n_epochs=12n_iter=10prog.start(n_epochs=n_epochs,n_iter=n_iter,leave_freq=4)for_inrange(n_epochs):for_inrange(n_iter):time.sleep(0.1)value=random.random()prog.update(value)Output4/12: ######################################## 100% [00:00:01.06] loss: 0.34203 
 8/12: ######################################## 100% [00:00:01.05] loss: 0.47886 
12/12: ######################################## 100% [00:00:01.05] loss: 0.40241unitArgument that multiple epochs as a unit.n_epochs=12n_iter=10prog.start(n_epochs=n_epochs,n_iter=n_iter,unit=4)for_inrange(n_epochs):for_inrange(n_iter):time.sleep(0.1)value=random.random()prog.update(value)Output1-4/12: ######################################## 100% [00:00:04.21] value: 0.49179 
  5-8/12: ######################################## 100% [00:00:04.20] value: 0.51518 
 9-12/12: ######################################## 100% [00:00:04.18] value: 0.54546Add noteYou can add a note to the progress bar.n_iter=10prog.start(n_iter=n_iter,note='This is a note')for_inrange(n_iter):time.sleep(0.1)value=random.random()prog.update(value)Output1: ######################################## 100% [00:00:01.05] 0.58703, This is a noteYou can also add a note whenupdate()asnoteargument.Also, you can add a note when end of epoch usin memo() ifdefer=True.n_epochs=3prog.start(n_epochs=n_epochs,n_iter=len(trainloader),label='train_loss',defer=True,width=20,)for_inrange(n_epochs):forx,labelintrainloader:optimizer.zero_grad()y=model(x)loss=criterion(y,label)loss.backward()optimizer.step()prog.update(loss.item())test_loss=eval_model(model)prog.memo(f'test_loss:{test_loss:.5f}')Output1/3: #################### 100% [00:00:02.83] train_loss: 0.34094, test_loss: 0.18194 
2/3: #################### 100% [00:00:02.70] train_loss: 0.15433, test_loss: 0.12987 
3/3: #################### 100% [00:00:02.79] train_loss: 0.10651, test_loss: 0.09783Multiple valuesIf you want to aggregate multiple values, setn_valuesand input values as a list.n_epochs=3n_iter=10prog.start(n_epochs=n_epochs,n_iter=n_iter,n_values=2)for_inrange(n_epochs):for_inrange(n_iter):time.sleep(0.1)value1=random.random()value2=random.random()*10prog.update([value1,value2])Output1/3: ######################################## 100% [00:00:01.05] 0.47956, 4.96049 
2/3: ######################################## 100% [00:00:01.05] 0.30275, 4.86003 
3/3: ######################################## 100% [00:00:01.05] 0.43296, 3.31025You can input multiple labels as a list instead ofn_values.prog.start(n_iter=n_iter,label=['value1','value2'])Default attributesProgressobject keeps constructor arguments as default attributes.These attributes are used when not specified instart().Attributes specified instart()is used preferentially while this running (until nextstart()orreset()).If a required attribute (n_iter) has already been specified,start()can be skipped.Version History1.0.0(2023-07-13)AddProgressclass.Addtrain_progressfunction.1.1.0(2023-07-13)Addvaluesattribute.Addleave_freqargument.Addunitargument.1.2.0(2023-09-24)Addnoteargument,memo()method, anddeferargument.Support multiple values.Addroundargument.Support changing separator strings.Support skippingstart().Write API Reference.Other minor adjustments.1.2.1(2023-09-25)Supportnote=Noneinmemo().Change timing of note reset from epoch_reset to bar_reset.1.2.2(2023-09-25)Fix bug that not setnote=Nonedefaultly inmemo().1.2.3(2023-11-28)Fix bug that argumentlabelis not available whenwith_test=Trueintrain_progress().1.2.4(2023-11-29)Fix bug that argumentwidthis not available whenwith_test=Trueintrain_progress().1.2.5(2024-01-17)Addget_all_values()method.Addget_all_times()method.1.2.6(2024-01-18, Latest)Fix bug that the time (minutes) is not displayed correctly.