I have two tensors:
import torch
target = torch.randint(2, (3,5)) #tensor of 0s & 1s
pred = torch.rand(3, 5) #tensor of prob
# transformed_pred = ?
How can I choose a cutoff probability to transform pred into a tensor of 0s & 1s (transformed_pred) so that the dot product between target and transformed_pred is maximized?
Thanks!
Maybe I am misunderstanding your question, but the cutoff probability should be 0.0. --> If you always choose 1, your dot product will always be equal to the sum of the non-zero elements in your target tensor, which is the maximum.
Are there any other constraints you haven't mentioned?