I have a tensor tcls of shape (n_objects, n_classes) and a 1 dim tensor for classes targets[…, 5][obj]. I would like to set for each row “n” of tcls the “nth” element of targets[…, 5][obj].
tcls = torch.zeros_like(preds[..., 5:][obj], device=config.DEVICE)
new_tcls = "how can I do it?"
lcls = self.BCE_cls(preds[..., 5:][obj], new_tcls) # BCE
Any suggestion?
I know I could do I with a naive for loop, but I am striving to learn it in a “linear algebra” way to enhance GPU computations