Right, in this case it seems you actually want to reduce across the second and third dimensions (I think a good way to think about this is which dimensions would you be averaging across to calculate the corresponding mean?). Does uncertainty_prediction = torch.std(total_prediction,dim=(1,2)) work?