rxtan2 / Learning-Similarity-Conditions

46 stars 15 forks source link

RuntimeError: The expanded size of the tensor (64) must match the exi sting size (96) at non-singleton dimension 1. Target sizes: [96, 64]. Ten sor sizes: [96] #12

Closed zhenxing-li closed 1 year ago

zhenxing-li commented 2 years ago

Traceback (most recent call last): File "D:/LZX/Learning-Similarity-Conditions-master/main.py", line 361, in main()
File "D:/LZX/Learning-Similarity-Conditions-master/main.py", line 166, in main train(train_loader, tnet, criterion, optimizer, epoch) File "D:/LZX/Learning-Similarity-Conditions-master/main.py", line 197, in train dista, distb, mask_norm, embed_norm, mask_embed_norm = tnet(data1, data2, data3, c) File "D:\anaconda\envs\TF2.1\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "D:\LZX\Learning-Similarity-Conditions-master\tripletnet.py", line 36, in forward general_x = general_x / norm.expand_as(general_x) RuntimeError: The expanded size of the tensor (64) must match the existing size (96) at non-singleton dimension 1. Target sizes: [96, 64]. Tensor sizes: [96]

Process finished with exit code 1

rxtan2 commented 2 years ago

Hi Zhenxing, do you mind trying to run the code on a single GPU and see if you are still getting the same result?

TYZXD commented 2 years ago

Traceback (most recent call last): File "D:/LZX/Learning-Similarity-Conditions-master/main.py", line 361, in main() File "D:/LZX/Learning-Similarity-Conditions-master/main.py", line 166, in main train(train_loader, tnet, criterion, optimizer, epoch) File "D:/LZX/Learning-Similarity-Conditions-master/main.py", line 197, in train dista, distb, mask_norm, embed_norm, mask_embed_norm = tnet(data1, data2, data3, c) File "D:\anaconda\envs\TF2.1\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "D:\LZX\Learning-Similarity-Conditions-master\tripletnet.py", line 36, in forward general_x = general_x / norm.expand_as(general_x) RuntimeError: The expanded size of the tensor (64) must match the existing size (96) at non-singleton dimension 1. Target sizes: [96, 64]. Tensor sizes: [96]

Process finished with exit code 1

I have the same problem with you. Did yo solve it? Thank you

TYZXD commented 2 years ago

solution of same problem : https://stackoverflow.com/questions/68868354/the-expanded-size-of-the-tensor-64-must-match-the-existing-size-66-at-non-si