Is there any way I can calculate the mean of all elements in a 4d tensor except along dim 0 - i.e. the equivalent of tensor.mean(1).mean(1).mean(1)
?
if you know the size of the first dimension you can:
tensor.view(size,-1).mean(1)
1 Like
And if you don’t know it, you could use:
tensor.view(tensor.size(0), -1).mean(1)
2 Likes
You can also do:
tensor.flatten(1).mean(1)