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
RuntimeError: Invalid index in scatter at /pytorch/aten/src/TH/generic/THTensorEvenMoreMath.cpp:151 #120
Comments
You should write an RAP.py by yourself and confirm that self.num_train_pids == 1295. The training set of Market1501 has 751 IDs, so the self.num_train_pids == 751 in Market1501. |
Thank you for your reply. I have already written a script for RAP dataset. The same problem is asked in these links but there is no solution for it: Here is the code that I have developed with extra assertions that you suggest. I have brought the logs also. As you can see, the number of features in the last layer is 1295 which is compatible with the number of train IDs. I have resized the images to 128*64 also but it didn't help. I have selected only 751 IDs to see maybe the problem is solved, but it didn't help also. Any suggestion?
The logs are as follows:
|
When I reordered the IDs from zero, the error disappeared.
|
First, I should mention that the code is working for the
Market1501
dataset properly.I want to train the network on the RAP dataset. I have created a
rap.py
as to below. I tried to mimic themarket1501.py
. When the training starts, it runs to aRunTimeError
. I debugged the code, and I think everything goes on exactly likemarket1501.py
, but I don't know the reason for this error. The error comes fromforward
function intriplet_loss.py
, where we have:targets = torch.zeros(log_probs.size()).scatter_(1, targets.unsqueeze(1).data.cpu(), 1)
I debugged and realized that the size of
inputs
is[8, 1295]
and the size oftargets
is[8]
, (when I debug the code formarket1501
, these sizes are[8, 751]
and[8]
, respectively). I should add that,batch size
is8
, number ofids
in RAP and market1501 are1295
and751
respectively. Changing theimages' size
andbatch size
do not help.The code for rap dataset (
rap.py
) is as follows:ERROR tracebak:
Logs/initialization:
POSSIBLE PROBLEM:
751
but thescatter
sees1295
size array. I am a newbie in PyTorch, could you please guide me through it?The text was updated successfully, but these errors were encountered: