auspicious3000/AutoPST

請問我該如何解決 repeats has to be Long tensor 的問題?(How to solve a problem)

chullin opened this issue · 2 comments

Sorry, I’m not familiar with English grammar, please forgive me if I offend.
I want to try to execute this Github project, but failed.
The only changed part of the program is (Because i don't have GPU)

(prepare_train_data.py)

device = 'cuda:0' (Change to the following line)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

Run >python main_1.py
Problem Description:RuntimeError: repeats has to be Long tensor
圖片3

Would i ask for help?
I will be grateful for any help you can provide.

Please make sure num_rep is a long tensor.

Thank you very much for your help, I have solved the problem

The following is my solution:
In torch.Tensor — PyTorch 1.9.1 documentation found that long tensor is 64-bit integer (signed)
Then print num_rep[i] in line 152 of model_autopst.py to know it dtype = torch.int32
And use num_rep = num_rep.to(torch.int64) to convert its type


152. num_rep = num_rep.to(torch.int64)
153.          for i in range(B):
154.              code_sync = cd_short[i].repeat_interleave(num_rep[i], dim=0)
155.              out_tensor[i, :len_long[i]-1, :] = code_sync