facenet_pytorch icon indicating copy to clipboard operation
facenet_pytorch copied to clipboard

RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn

Open HiYellowC opened this issue 5 years ago • 0 comments

out_selected_a = Variable(torch.from_numpy(out_a.cpu().data.numpy()[hard_triplets]).cuda()) out_selected_p = Variable(torch.from_numpy(out_p.cpu().data.numpy()[hard_triplets]).cuda()) out_selected_n = Variable(torch.from_numpy(out_n.cpu().data.numpy()[hard_triplets]).cuda())

will lead to

RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn

why not use:

out_selected_a = out_a[hard_triplets] out_selected_p = out_p[hard_triplets] out_selected_n = out_n[hard_triplets]

HiYellowC avatar May 14 '19 09:05 HiYellowC