代码使用:
from tqdm import tqdm
import sys
#Testing
def test(model, testLoader, topk=(1,)):
model.eval()
# 只是多了下面这一行
testLoader = tqdm(testLoader, file=sys.stdout)
with torch.no_grad():
for batch_idx, (inputs, targets) in enumerate(testLoader):
inputs, targets = inputs.to(device), targets.to(device)
outputs = model(inputs)
loss = loss_func(outputs, targets)
...
输出:
4%|████ | 8/196 [00:10<03:25, 1.09s/it]