【笔记】tqdm 进度条:desc(‘str‘): 传入进度条的前缀,mininterval(float):最小的更新时间 [default: 0.1] sec,set_postfix : 设置信息

附:【笔记】python 中 *args 和 **kwargs 的用法:*args 无关键字参数,接收元组、列表;**kwargs 有关键字参数,接收字典_nyist_yangguang的博客-CSDN博客

注: f"{}" 的说明:

eg1:

from tqdm import tqdm
import time
epoch_size=100
Epoch=1000
epoch=45

with tqdm(total=epoch_size, desc=f'Epoch {epoch + 1}/{Epoch}', postfix=dict, mininterval=0.01) as pbar:
    for i in range(10):
        time.sleep(0.5)
        tqdm(total=epoch_size, desc=f'Epoch {epoch + 1}/{Epoch}', postfix=dict,mininterval=1)
        pbar.update(1)

 

 

eg2:

 

eg3:

附:

 跳转中...

from tqdm import tqdm, trange
from random import random, randint
from time import sleep

#trange 是tqdm(range)的简用方式:
for i in trange(int(1e8)):
    pass 

for i in trange(int(1e8),miniters = int(1e6),ascii= True,desc ='bar',colour = 'blue',mininterval = 0.5):
    pass


with trange(10) as t:
    for i in t:
        # Description will be displayed on the left
        t.set_description('GEN %i' % i)
        # Postfix will be displayed on the right,
        # formatted automatically based on argument's datatype
        t.set_postfix(loss=random(), gen=randint(1,999), str='h',
                      lst=[1, 2])
        sleep(0.1)

with tqdm(total=10, bar_format="{postfix[0]} {postfix[1][value]:>8.2g}",
          postfix=["Batch", dict(value=0)]) as t:
    for i in range(10):
        sleep(0.1)
        t.postfix[1]["value"] = i / 2
        t.update()

  • 4
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序猿的探索之路

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值