问题遇到的现象和发生背景
我想把数据分到十个客户端去训练,使用tqdm显示客户端内的训练进度
遇到的现象和发生背景,请写出第一个错误信息
没有报错,但是进度条异常
用代码块功能插入代码,请勿粘贴
def train(df, w):
traindata, labels = load_data(df, 'train')
for ep in tqdm(range(epoch)):
for it in range(traindata.size(0)):
w = logistic_regression(traindata[it], w, labels[it])
print('\n')
return w
运行结果及详细报错内容
desc: 0%| | 0/1 [00:00<?, ?it/s]epoch 1 train ...
client 1 start train ...
client 2 start train ...
desc: 100%|██████████| 1/1 [00:00<00:00, 1.14it/s]
desc: 100%|██████████| 1/1 [00:00<00:00, 1.15it/s]
client 3 start train ...
desc: 100%|██████████| 1/1 [00:00<00:00, 1.14it/s]
……
……
client 6 start train ...
desc: 100%|██████████| 1/1 [00:00<00:00, 1.14it/s]
desc: 0%| | 0/1 [00:00<?, ?it/s]
client 7 start train ...
desc: 100%|██████████| 1/1 [00:00<00:00, 1.16it/s]
desc: 0%| | 0/1 [00:00<?, ?it/s]
client1的进度条在client2下,client3正常,client6和7下出现空进度条,正常应该是client3下展示的情况
我的解答思路和尝试过的方法
考虑过是不是tqdm和print冲突,也没有解决。整个代码只有这个函数中用到了tqdm,最后输出时代码如下;
for i in range(10):
print('client %d start train ...'%(i+1))
w = train(data[i], g_w)
l_w += w
我想要达到的结果
client3下进度条显示样式:
client 3 start train ...
desc: 100%|██████████| 1/1 [00:00<00:00, 1.14it/s]