progress bar with tqdm

d4r6j·2023년 8월 23일

ml modeling

목록 보기
1/6
post-thumbnail

  • tqdm object 생성.

    train_progress = tqdm.tqdm(iterable=data_train
               , bar_format="{l_bar}{bar:25}{r_bar}"
               , colour="magenta"
               , total=len(data_train)
               , leave=True)

  • leave option

    If [default: True], keeps all traces of the progressbar upon termination of iteration. If None, will leave only if position is 0.

    leave=[True/False]

    True 일 경우 iteration 이 한 번 끝날 때마다, 모든 추적을 유지하는데 False 일 경우 iteration 이 한 번 끝나면, 사라지게 된다. None 이면 position 은 0.

  • bar_format option

    Specify a custom bar string formatting. May impact performance.

    "{l_bar}{bar:25}{r_bar}"

  • progress bar 업데이트
    # update progress bar
    train_progress.set_description(f"train [{epoch + 1}/{_epoch}]")
    str_train_loss= '{:.3f}'.format(round(trainLoss.item(), 3))
    str_train_metric= '{:.3f}'.format(round(trainAccuracy, 3))
    train_progress.set_postfix(loss=str_train_loss, acc=str_train_metric)
  • set_description option

    set_postfix(loss=trainLoss, acc=trainAccuracy)
  • set_postfix option

    set_postfix(loss=trainLoss, acc=trainAccuracy)

    Set/modify postfix (additional stats) with automatic formatting based on datatype.

0개의 댓글