YouTip LogoYouTip

Pytorch Torch Mean

# PyTorch torch.mean Function * * * [![Image 3: Pytorch torch Reference Manual]( Pytorch torch Reference Manual]( `torch.mean` is a function in PyTorch used to calculate the mean of a tensor. ### Function Definition torch.mean(input, dim, keepdim, dtype, out) * * * ## Usage Examples ## Example import torch x = torch.tensor([[1,2,3],[4,5,6]]) # Calculate mean of all elements print("Global mean:", torch.mean(x)) # Calculate mean along dim=0 print("dim=0 mean:", torch.mean(x, dim=0)) Output result: Global mean: tensor(3.5000) dim=0 mean: tensor([2.5000, 3.5000, 4.5000]) * * * [![Image 4: Pytorch torch Reference Manual]( Pytorch torch Reference Manual](
← Pytorch Torch MeshgridPytorch Torch Max β†’