Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

335
Views
tqdm no muestra la barra

Estoy usando la biblioteca tqdm y no me da la barra de progreso, sino que me da un resultado que se ve así, donde solo me dice la iteración:

251it [01:44, 2.39it/s]

¿Alguna idea de por qué el código haría esto? Pensé que tal vez era porque le estaba pasando un generador, pero nuevamente he usado generadores en el pasado que han funcionado. Realmente nunca antes me había metido con el formato tdqm. Aquí está parte del código fuente:

 train_iter = zip(train_x, train_y) #train_x and train_y are just lists of elements .... def train(train_iter, model, criterion, optimizer): model.train() total_loss = 0 for x, y in tqdm(train_iter): x = x.transpose(0, 1) y = y.transpose(0, 1) optimizer.zero_grad() bloss = model.forward(x, y, criterion) bloss.backward() torch.nn.utils.clip_grad_norm(model.parameters(), args.clip) optimizer.step() total_loss += bloss.data[0] return total_loss
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

tqdm necesita saber cuántas iteraciones se realizarán (la cantidad total) para mostrar una barra de progreso.

Puedes probar esto:

 from tqdm import tqdm train_x = range(100) train_y = range(200) train_iter = zip(train_x, train_y) # Notice `train_iter` can only be iter over once, so i get `total` in this way. total = min(len(train_x), len(train_y)) with tqdm(total=total) as pbar: for item in train_iter: # do something ... pbar.update(1)
over 4 years ago · Santiago Trujillo Report

0

Rellenar el parámetro "total" con la longitud funcionó para mí. Ahora aparece la barra de progreso.

 from tqdm import tqdm # ... for imgs, targets in tqdm( train_dataloader, total=len(train_dataloader)): # ...
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!