Hi Nadia!



 NadiaMe:

I have the following tensor T=[100, 10, 10]
I want to find max for each of the 100 matrices and get output [100].


T.max (dim = -1)[0].max (dim = -1)[0] should work, or you can
use the equivalent torch.max() version, if you prefer.  (This could also
be written T.max (dim = 2)[0].max (dim = 1)[0].)
(If you want to be courageous, you could try the unstable, nightly build,
e.g., version “1.8.0.dev20201021,” and run T.amax (dim = (1, 2)).)


When I run
out = torch.max(T, dim=0)[0]
I get 2d output of size [10, 10].
What does it mean and why I dont get 1d output of size 100 ?


dim = 0 doesn’t mean “keep dim 0.”  It means take the max() over
dim 0.  So it builds tensor of shape [10, 10], each element of which
is the max() of 100 values, namely the max() of the corresponding
elements of the 100 shape-[10, 10] slices of your original tensor.
Best.
K. Frank