首页 > 编程知识 正文

arrays.copyofrange用法,查询表达式里用了tolist

时间:2023-05-04 00:23:52 阅读:19282 作者:3721

链接: torch.Tensor.tolist (请参阅

原文及翻译:

tolist ()方法: tolist ) (“to list”- list or number to list ) ) -列表或数字returnsthetensorasa(nested ) list. For scalars,) just like with item ().tensorsareautomaticallymovedtothecpufirstifnecessary .以一个(嵌套表达式的)列表的形式返回一个健壮的中午。 如果这个结实的白天是一个标量的话,是一个标准的Python数字。和用法item ()一样。 如果需要,转换前结实的中午首先自动移动到CPU。 thisoperationisnotdifferentiable )此操作不可微分(不能求导数求梯度)。因为译者注释:返回列表,所以自然会调用backward (方法反向传播梯度) (Examples:例:a=Torch.Randn ) 2,2 ) a.tolist ) [ 0.012766935862600803,0.541547358803 ] ) 0.01276666000000808 0.777

Microsoft windows [ 10.0.18363.1316版] [ c ] 2019 Microsoft corporation。 保留一切权利。 c : _ users _ chenxuqicondaactivatessd4py torch1_2_0(SSD4py torch1_2_0) c : _ SERS _ chenxu qipythonpythonpythython ) ] : Anaconda,Inc. on win32Type 'help ',' copyright ', ' credits ' or ' license ' for more information.importtorchtorch.manual _ seed (torch._ c.generatorobjectat0x 0000021666516506 t ) torch.cuda.is 2) atensor([0.2824,-0.3715],[ 0.9088,-1.7601]] ) a.shapetorch.size ) [ 2,2 ] ) a.tte )。 [0.908775269985199,- 1.7601189613342285 ] print (a.to list ([ 0.282388957500458,-0.37148377299308777],0.282383885008 - 1.7601189613342285 ] a [ 0,0 ].to list (0.28238889500458 print (a [ 0,0 ].to list ) ) 0.282388889500458a(0) cc [ 1.1216,0.8440 ],device='cuda:0 ' ) a 2.0936813354492188],[1.040623426437378,-1.7651376724243164],[ 1. [ 1.1216,0.8440 ],设备=' cuda :0 ' ) a [ 0,1 ] tensor [ 2.0937,设备=' cuda :0 ' ] a [ 0, 1].shapettor 1) ).tolist ) 2.0936813354492188 a=torch.randn (1) a.shapetorch.size([1]atensor ) [0.1783] 设备=' cuda :0 ' ) a.tolist ) [0.6858752369880676]atensor ) [0.68859], evice=' cuda :0 ' (a=torch.randn (1) atensor([-1.5942] ) a.tolist ) (-1.594219326929614 ) a=torch.- 0.2005603164434433 print (a.to list ((0.20056031643444433 t=a.to llo ' float' a=torch.randn () ) ).cuda ) ) atensor(-0.4050,dvice=' cuda :0 ' (a.to list (-0.40504276660 ) class'float'type(3.14 ) class ' float ' a.shape torch.size ([ ] a.item )-0.40504276752471924 d=a.item ) ) dvice=' cuda :0 ' (d-0.40504276752471924 type (d ) class 'float'type(3.14 ) class 'float () ) ) ) ) clalarat

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。