how to calculate cross entropy in 3d image pytorch?
See the figure here

left thing is (2, 480, 640) and it's softmax value

right thing is (2, 480, 640) and it's one-hot encoding value

how to get cross entropy loss in all element? 

Exactly the same way as with any other image. Use binary_cross_entropy(left, right). Note that


Both have to be of torch.float32 dtype so you may need to first convert right using right.to(torch.float32).
If your left tensor contains logits instead of probabilities it is better to call binary_cross_entropy_with_logits(left, right) than to call binary_cross_entropy(torch.sigmoid(left), right)

