Hello all, I have a custom loss that only worked for 4D tensors such as NxBxHxW. However, I want to use the loss for my data that is 5D tensor such as NxBxDxHxW. I am wondering which way is fastest way to use the loss for my input, and how to use it? I hear that we can use the view() function. Thanks
This is the example use the loss for 4D tensor
s = myloss()
a = torch.randint(0, 255, size=(20, 3, 256, 256), dtype=torch.float32).cuda() / 255.
b = a * 0.5
a.requires_grad = True
b.requires_grad = True
loss = s(a, b)
loss.backward()