LoginSignup
0
0

More than 1 year has passed since last update.

tqdmのインポートミス

Posted at

はじめに

for文などで重めの処理や、Pytorchでの学習などの進捗管理のために使うことも多いtqdm。

importするときによくミスるのでメモ。

Pytorchでの学習を回す時を例に挙げます。

環境

python 3.9.5
macOS 12.0 beta

ダメな例

import tqdm

for inputs, labels in tqdm(train_dataloader):
# ---以下学習処理----

これだと'module' object is not callableとエラーが出る。モジュールは関数として呼べないよって意味。

良い例

from tqdm import tqdm

for inputs, labels in tqdm(train_dataloader):
# ---以下学習処理----
import tqdm

for inputs, labels in tqdm.tqdm(train_dataloader):
# ---以下学習処理----

これでうまくいった。

まとめ

モジュールと関数の違いをちゃんと理解する。

でもモジュール名と関数名が一緒なのややこしい...。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0