How to analyze the usage examples of torch.mean () and mean (dim=None, keepdim=False)
How to analyze with examples of torch.mean () and mean (dim=None, keepdim=False). For this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
The code experiment shows:
Microsoft Windows [version 10.0.18363.1256] (c) 2019 Microsoft Corporation. All rights reserved. C:\ Users\ chenxuqi > C:\ Users\ chenxuqi > conda activate ssd4pytorch2_2_0 (ssd4pytorch2_2_0) C:\ Users\ chenxuqi > pythonPython 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)]:: Anaconda, Inc. On win32Type "help", "copyright", "credits" or "license" for more information. > > import torch > > torch.manual_seed (seed=20200910) > > a = torch.randn (4,3) > > atensor ([[0.2824,-0.3715)] 0.9088], [- 1.7601,-0.1806, 2.0937], [1.0406,-1.7651, 1.1216], [0.8440, 0.1783, 0.6859]) > torch.mean (a) tensor (0.2565) > atensor ([[0.2824,-0.3715,0.9088], [- 1.7601,-0.1806,2.0937], [1.0406,-1.7651,1.1216], [0.8440] 0.1783, 0.6859]) > > torch.mean (a, 1) tensor ([0.2732, 0.0510, 0.1324, 0.5694]) > > torch.mean (a, 0) tensor ([0.1017,-0.5347, 1.2025]) > torch.mean (input=a, dim=0, keepdim=False) tensor ([0.1017,-0.5347,1.2025]) > torch.mean (input=a, dim=1, keepdim=False) tensor ([0.2732,0.0510,0.1324]) 0.5694]) > torch.mean (input=a, dim=0, keepdim=True) tensor ([0.1017,-0.5347, 1.2025]]) > > torch.mean (input=a, dim=1, keepdim=True) tensor ([[0.2732], [0.0510], [0.1324], [0.5694]]) > on the use of torch.mean () and mean (dim=None, keepdim=False) examples of how to analyze questions are shared here. I hope the above content can help you to a certain extent, if you still have a lot of doubts to be solved, you can follow the industry information channel to learn more related knowledge.