CompVis / metric-learning-divide-and-conquer

Source code for the paper "Divide and Conquer the Embedding Space for Metric Learning", CVPR 2019

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError: '_SingleProcessDataLoaderIter' object has no attribute 'dataset'

Roberto7766 opened this issue · comments

Hi,
I get the error in the title.

Here the command:
CUDA_VISIBLE_DEVICES=0 python experiment.py --dataset=inshop --dir=test --exp=0 --random-seed=0 --nb-clusters=8 --nb-epochs=200 --sz-batch=80 --backend=faiss-gpu --embedding-lr=1e-5 --embedding-wd=1e-4 --backbone-lr=1e-5 --backbone-wd=1e-4 --finetune-epoch=190

And this the result:
2020-11-25 17:20:21,744 Evaluating initial model...
predict: 100%|█████████████████████████████████████████████████████████████████████████████████████| 178/178 [01:27<00:00, 2.04it/s]
predict: 100%|█████████████████████████████████████████████████████████████████████████████████████| 158/158 [01:14<00:00, 2.12it/s]
2020-11-25 17:23:12,386 R@1 : 21.241
2020-11-25 17:23:12,451 R@10 : 42.580
2020-11-25 17:23:12,512 R@20 : 50.274
2020-11-25 17:23:12,573 R@30 : 54.726
2020-11-25 17:23:12,634 R@50 : 60.100
predict: 100%|█████████████████████████████████████████████████████████████████████████████████████| 324/324 [02:37<00:00, 2.06it/s]
Clustering 25882 points in 2048D to 8 clusters, redo 1 times, 100 iterations
Preprocessing in 0.14 s
Iteration 99 (10.39 s, search 3.73 s): objective=4311.43 imbalance=1.125 nsplit=0
2020-11-25 17:26:03,613 Training for 200 epochs.
Train epoch 0.: 0%| | 0/424 [00:00<?, ?it/s]
Traceback (most recent call last):
File "experiment.py", line 66, in
train.start(config)
File "/home/roberto/PersonReID/metric-learning-divide-and-conquer/train.py", line 287, in start
desc = 'Train epoch {}.'.format(e)
File "/home/roberto/anaconda3/envs/metric-learning/lib/python3.6/site-packages/tqdm/std.py", line 1193, in iter
for obj in iterable:
File "/home/roberto/PersonReID/metric-learning-divide-and-conquer/lib/data/loader/utils.py", line 96, in merge
yield b, dls[i].dataset
AttributeError: '_SingleProcessDataLoaderIter' object has no attribute 'dataset'

In effect in the code (utils.py):
for j in range(nb_batches):
for i in I:
b = next(dls[i], None)
if b == None:
# initialize new dataloader in case no batches left
dls[i] = iter(dls_non_iter[i])
b = next(dls[i])
yield b, dls[i].dataset

dls does not have 'dataset' attribute.
By the way, I had to set 'num_workers' to 0 to make it run.

What shall I do?
Thanks

It is probably because you use new pytorch. And the code was implemented using pytorch 0.4.1.

In the latest pytoch they renamed the field.
Try changing dls[i].dataset - > dls[i]._dataset.

Hope it helps!

It works, thank you!