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

new dataset with some problem #5

Open
Jinjicheng opened this issue Aug 28, 2018 · 3 comments
Open

new dataset with some problem #5

Jinjicheng opened this issue Aug 28, 2018 · 3 comments

Comments

@Jinjicheng
Copy link

i run your code with new dataset(MSMT17),but it occured :
[INFO] Making model...
[INFO] Making loss...
1.000 * CrossEntropy
1.000 * Triplet
[INFO] Epoch: 1 Learning rate: 2.00e-04
[INFO] [1/160] 65/66 [CrossEntropy: 9.6161][Triplet: 3.0369][Total: 12.6529]Traceback (most recen
t call last):
File "main.py", line 20, in
trainer.train()
File "G:\code2\MGN-pytorch-master\trainer.py", line 50, in train
loss.backward()
File "D:\Anaconda3\lib\site-packages\torch\tensor.py", line 93, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "D:\Anaconda3\lib\site-packages\torch\autograd_init_.py", line 89, in backward
allow_unreachable=True) # allow_unreachable flag
RuntimeError: The expanded size of the tensor (1) must match the existing size (0) at non-singleton
dimension 0
how to solve it.

@lianfenghua
Copy link

@Jinjicheng When I used another dataset (Mars) to train, the same error occured. The error would disappear if the parameter --batchid was setted as another value (e.g. --batchid 5), though I do not know the reason behind it.

@Jinjicheng
Copy link
Author

i know it.For example,ids of train is 1041,batchid and batchimg is (16,4). Every batch has 16 id, but last batch
has only 1 id,it is incompatible Triplet loss.

@lianfenghua
Copy link

So that explains it. If ids = 1041 and batchid = 16, then because 1041/16 = 65...1, the number of batches is 66, where the first 65 batches have 16 ids and the last batch has only one id. However calculatig triplet loss needs two examples with different labels (ids). Thanks.

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

2 participants