Torch.var and torch.mean output shape different

I think the two closely related functions torch.var and torch.mean should have the same output shape, but this is not true. Is there any reason for this?

a = torch.randn(4,3)
a.var(1, True).shape # (4)
a.mean(1, True).shape # (4,1)

Apparently var is ignoring the keepdims argument.

That’s not the case and you should explicitly specify the keepdim argument which works fine:

a.var(1, keepdim=True).shape
# torch.Size([4, 1])
a.mean(1, keepdim=True).shape
# torch.Size([4, 1])

In your current code the True argument in var would be passed to correction instead of keepdim as seen in the docs.

Oh I see. My mistake. Thanks!