Torch.mean() misunderstand


(Mohammed Awney) #1

I can not understand how to evaluate this expression:
x.view(*(x.shape[:-2]),-1).mean(-1), x in shape(N, C, H, W)
what is the astrick ? and what is mean(-1) ?
Thanks in advance


(Lalu Erfandi Maula Yusnu) #2

@Mohammed_Awney
with asterisk you are passing list as args

def test(*args):
    print(args)
    
mylist = [5,3,32,32]

print(test(*mylist))
#the result is (5, 3, 32, 32)

(Mohammed Awney) #3

what about mean(-1) ??


#4

-1 as a dimension argument means the last dimension. -2 the last but one, etc.