yxgeee / FD-GAN

[NeurIPS-2018] FD-GAN: Pose-guided Feature Distilling GAN for Robust Person Re-identification.
https://yxgeee.github.io/projects/fdgan.html
281 stars 80 forks source link

IndexError: invalid index of a 0-dim tensor. #43

Closed absagargupta closed 4 years ago

absagargupta commented 4 years ago

On running the command python baseline.py -b 64 -j 4 -d market1501 -a resnet50 --combine-trainval --lr 0.01 --epochs 100 --step-size 40 --eval-step 5

I am getting the above said error. I am pasting the full traceback: Market1501 dataset loaded subset | # ids | # images

train | 651 | 11509 val | 100 | 1427 trainval | 751 | 12936 query | 750 | 16483 gallery | 751 | 19281 /home/sagar18174/.local/lib/python2.7/site-packages/torch/nn/parallel/data_parallel.py:26: UserWarning: There is an imbalance between your GPUs. You may want to exclude GPU 0 which has less than 75% of the memory or cores of GPU 1. You can do so by setting the device_ids argument to DataParallel, or by setting the CUDA_VISIBLE_DEVICES environment variable. warnings.warn(imbalance_warn.format(device_ids[min_pos], device_ids[max_pos])) Traceback (most recent call last): File "baseline.py", line 200, in main(parser.parse_args()) File "baseline.py", line 143, in main trainer.train(epoch, train_loader, optimizer, base_lr=args.lr) File "/home/sagar18174/Thesis/person_RE-identification/FD-GAN/reid/trainers.py", line 34, in train losses.update(loss.data[0], targets.size(0)) IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number Any help will be highly appreciated

yxgeee commented 4 years ago

I think change loss.data[0] to loss.item() could solve it. (.data[0] was used in older version of PyTorch)

absagargupta commented 4 years ago

Yes it solved it. thanks