首页 > 其他 > 详细

PyTorch学习问题记录

时间:2017-07-28 19:50:34      阅读:386      评论:0      收藏:0      [点我收藏+]

Q1:def train() 中的model.train()的作用是什么?为什么要写?

A1:class torch.nn.Module中 train(mode=True)

  Sets the module in training mode. This has any effect only on modules such as Dropout or BatchNorm.

  参看 http://pytorch.org/docs/master/nn.html

 

Q2:torch.gather() 和 torch.norm() 函数的功能是什么?

 1 t = torch.Tensor([[1, 2], [3, 4]])
 2 print(t)
 3 a = torch.gather(t, 1, torch.LongTensor([[0,0], [1,0]]))
 4 print(a)
 5 ‘‘‘
 6  1  2
 7  3  4
 8 [torch.FloatTensor of size 2x2]
 9 
10  1  1
11  4  3
12 [torch.FloatTensor of size 2x2]
13 ‘‘‘

 1 a = torch.FloatTensor([[1, 2], [3, 4]])
 2 b = torch.norm(a)
 3 print(a)
 4 print(b)
 5 ‘‘‘
 6  1  2
 7  3  4
 8 [torch.FloatTensor of size 2x2]
 9 
10 5.477225575051661
11 ‘‘‘

 

PyTorch学习问题记录

原文:http://www.cnblogs.com/Joyce-song94/p/7252206.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!