参考连接: torch.exp(input, out=None)
参考连接: exp()html
代码实验展现:
python
Microsoft Windows [版本 10.0.18363.1256] (c) 2019 Microsoft Corporation。保留全部权利。 C:\Users\chenxuqi>conda activate ssd4pytorch1_2_0 (ssd4pytorch1_2_0) C:\Users\chenxuqi>python Python 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import torch >>> import math >>> torch.manual_seed(seed=20200910) <torch._C.Generator object at 0x0000023D74B6D330> >>> >>> torch.exp(torch.tensor([0, math.log(2.)])) tensor([1., 2.]) >>> >>> math.log(2.) 0.6931471805599453 >>> input = torch.tensor([[0,1,2],[3,4,5]],dtype=torch.float) >>> input tensor([[0., 1., 2.], [3., 4., 5.]]) >>> torch.exp(input) tensor([[ 1.0000, 2.7183, 7.3891], [ 20.0855, 54.5981, 148.4132]]) >>> >>> >>> input = torch.randn(3,5) >>> input tensor([[ 0.2824, -0.3715, 0.9088, -1.7601, -0.1806], [ 2.0937, 1.0406, -1.7651, 1.1216, 0.8440], [ 0.1783, 0.6859, -1.5942, -0.2006, -0.4050]]) >>> torch.exp(input) tensor([[1.3263, 0.6897, 2.4813, 0.1720, 0.8348], [8.1147, 2.8310, 0.1712, 3.0699, 2.3256], [1.1952, 1.9855, 0.2031, 0.8183, 0.6669]]) >>> >>> >>>
本文同步分享在 博客“敲代码的小风”(CSDN)。
若有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一块儿分享。web