Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

RuntimeError: gather(): Expected dtype int64 for index #6

Closed
vpozdnyakov opened this issue Dec 15, 2021 · 2 comments
Closed

RuntimeError: gather(): Expected dtype int64 for index #6

vpozdnyakov opened this issue Dec 15, 2021 · 2 comments

Comments

@vpozdnyakov
Copy link

Hi, I got an error during validation step, here is a traceback:

image

As I understand, the variable perm_mask should be a tensor with integer values, but it is obtained from division in self.num_nodes in advance method as follows:

prev_k = bestScoresId / self.num_nodes
...
perm_mask = prev_k.unsqueeze(2).expand_as(self.mask)
self.mask = self.mask.gather(1, perm_mask)

So it looks like it cannot work in any case. Any help will be highly appreciated.

@vpozdnyakov
Copy link
Author

I have found a solution in this issue chaitjo/graph-convnet-tsp#16:

prev_k = bestScoresId // self.num_nodes

Please validate if it is correct for torch 1.10. It will also be great to fix this issue if it is correct for your setting Ubuntu 16.04, using Python 3.6.7, PyTorch 1.2.0 and CUDA 10.0. It can help people who trying to run the code on modern versions.

@chaitjo
Copy link
Owner

chaitjo commented Dec 20, 2021

Hi @vpozdnyakov, thank you for your interest!

Yes, the issue you have referenced can be a fix if you are using the latest PyTorch.

This codebase + empirical results were obtained using an older version of PyTorch 1.2, where I do not recall encountering the same issue. At the moment, I can consider updating the codebase(s) for my TSP projects, but I do not have the bandwidth and resources to actually test these changes or ensure that the results do not change dramatically. What do you suggest?

@chaitjo chaitjo closed this as completed Mar 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants