码迷,mamicode.com
首页 > 其他好文 > 详细

double函数和int函数

时间:2016-12-29 17:16:19      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:bsp   style   size   0.00   blog   整数   元素   pre   nbsp   

 

可以看到,当tensor全是double型时,int函数会把所有元素取整,从1.5可以看出,不是四舍五入,而是取整。double函数又把整数型元素变成double型。

th> a
 0.0000  2.0000  0.0000
 0.0000  1.5000  0.0000
[torch.DoubleTensor of size 2x3]

                                                                      [0.0002s]
th> a:int()
 0  2  0
 0  1  0
[torch.IntTensor of size 2x3]

                                                                      [0.0002s]
th> a:double()
 0.0000  2.0000  0.0000
 0.0000  1.5000  0.0000
[torch.DoubleTensor of size 2x3]

 

double函数和int函数

标签:bsp   style   size   0.00   blog   整数   元素   pre   nbsp   

原文地址:http://www.cnblogs.com/ymjyqsx/p/6233475.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!