Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors occur when running 'bash train_attMPTI.sh' #26

Open
neymar-jr opened this issue Feb 27, 2023 · 4 comments
Open

Errors occur when running 'bash train_attMPTI.sh' #26

neymar-jr opened this issue Feb 27, 2023 · 4 comments

Comments

@neymar-jr
Copy link

Errors are listed as below.

Traceback (most recent call last):
File "/home/liuxuanchen/Develop/few-shot-point-cloud/attMPTI/main.py", line 101, in
train(args)
File "/home/liuxuanchen/Develop/few-shot-point-cloud/attMPTI/runs/mpti_train.py", line 58, in train
loss, accuracy = MPTI.train(data)
File "/home/liuxuanchen/Develop/few-shot-point-cloud/attMPTI/models/mpti_learner.py", line 63, in train
query_logits, loss= self.model(support_x, support_y, query_x, query_y)
File "/home/liuxuanchen/anaconda3/envs/torch/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1194, in call_impl
return forward_call(*input, **kwargs)
File "/home/liuxuanchen/Develop/few-shot-point-cloud/attMPTI/models/mpti.py", line 107, in forward
A = self.calculateLocalConstrainedAffinity(node_feat, k=self.k_connect)
File "/home/liuxuanchen/Develop/few-shot-point-cloud/attMPTI/models/mpti.py", line 258, in calculateLocalConstrainedAffinity
A = A.scatter
(1, I, knn_similarity)
RuntimeError: Expected index [4396, 200] to be smaller than self [4396, 4396] apart from dimension 1 and to be smaller size than src [4396, 192]

@mayur20169
Copy link

I am also getting exactly same error.

@suurajroshan
Copy link

I get a similar error too. Did anyone get a solution to this error?

@WeiTang-code
Copy link

WeiTang-code commented Nov 10, 2023

It may be something wrong with faiss. I've managed to run the code successfully in another environment, but it gives me an error in a higher version of pytorch and cuda environment on a 30-series GPU. Now I get wrong knn_index.


Further troubleshooting revealed that it was not a faiss error, but a large number of "nan" in the tensor of node_feat, which comes from the prototype.


I have solved this problem. It comes from the function "pytorch.nn.functional.pairwise_distance". This function behaves differently in different versions of pytorch.

If you use pytorch of higher version, you can refer to my solution. Note that every use of the "pairwise_distance" function requires modification.

distances = F.pairwise_distance(feat[..., None].transpose(1,2), farthest_seeds[None, ...], p=2) # (n_points, n_prototypes)

@xin1106
Copy link

xin1106 commented Sep 5, 2024

@WeiTang-code Your answer is very helpful.
I encountered an error while running the protonet.by :
Runtime Error: Expected target size [2,192], got [2,2048].
Have you encountered this problem before.
For the 'similarity=- F.pairise_distance (feature, prototype [None, None], p=2)**2', how should I modify it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants