levyfan / reid-mgn

Reproduction of paper: Learning Discriminative Features with Multiple Granularities for Person Re-Identification
MIT License
153 stars 50 forks source link

TypeError: to() received an invalid combination of arguments - got (device), but expected one of: * (torch.device device, torch.dtype dtype) * (torch.dtype dtype) didn't match because some of the arguments have invalid types: (device) * (Tensor other) didn't match because some of the arguments have invalid types: (device) #6

Closed senlinxiaolangtaba closed 6 years ago

senlinxiaolangtaba commented 6 years ago

When I carried out the project I got this promblem: Traceback (most recent call last): File "/home/bruce/mgn/mgn/mgn.py", line 300, in run() File "/home/bruce/mgn/mgn/mgn.py", line 243, in run mgn = MGN(num_classes=len(train_dataset.unique_ids)).to(DEVICE) File "/home/bruce/.conda/envs/snowflake/lib/python3.6/site-packages/torch/nn/modules/module.py", line 393, in to return self._apply(lambda t: t.to(device)) File "/home/bruce/.conda/envs/snowflake/lib/python3.6/site-packages/torch/nn/modules/module.py", line 176, in _apply module._apply(fn) File "/home/bruce/.conda/envs/snowflake/lib/python3.6/site-packages/torch/nn/modules/module.py", line 176, in _apply module._apply(fn) File "/home/bruce/.conda/envs/snowflake/lib/python3.6/site-packages/torch/nn/modules/module.py", line 182, in _apply param.data = fn(param.data) File "/home/bruce/.conda/envs/snowflake/lib/python3.6/site-packages/torch/nn/modules/module.py", line 393, in return self._apply(lambda t: t.to(device)) TypeError: to() received an invalid combination of arguments - got (device), but expected one of:

levyfan commented 6 years ago

python2 or python3? I only test with python2. https://pytorch.org/docs/stable/tensors.html#torch.Tensor.to You can print DEVICE and check pytorch doc to(device, dtype=None) → Tensor

levyfan commented 6 years ago

Also make sure to use pytorch=0.4.0