Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use the new () method in torch

Shulou Source: shulou.com Published: 2022-06-02 05:44:54 10月03日 Update

This article will explain in detail how to use the new () method in torch. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.

Microsoft Windows [version 10.0.18363.1256] (c) 2019 Microsoft Corporation. All rights reserved. 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.zeros (3CM4) > > atensor. 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.manual_seed (seed=20200910) > > a = torch.randn (3prime4) > atensor -0.3715, 0.9088,-1.7601], [- 0.1806, 2.0937, 1.0406,-1.7651], [1.1216, 0.8440, 0.1783, 0.6859]) > a.new (4) tensor ([0.,0.,0.,0.]) > a.new () tensor ([]) > a.new (5jin6) tensor ([[1.8370e+25, 1.4603e-19, 0.0000e+00, 0.0000e+00]) 2.1019e-44, 0.0000e+00], [- 3.0652e-36, 4.5916e-41, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 5.2751e-11, 0.0000e+00], [2.8026e-45, 1.1625e+33] -5.1397e-05, 4.5916e-41, 0.0000e+00, 0.0000e+00]) > > KeyboardInterrupt > > KeyboardInterrupt > a.new (5) tensor ([[1.7743e+28, 1.3458e-14], [1.2689e+31, 3.2745e-12], [7.5555e+31, 1.2705e+31], [3.2611e-12, 7.5555e+31], [1.2705e+31, 1.7225e+22]) > > a.new (3) tensor ([0.,0.) 0.]) > that's all about how to use the new () method in torch. I hope the above content can be of some help to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Method content article more knowledge article good right version quality reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker vpn Xiaomi Shulou Tech Info macOS