randperm函数

  randperm功能是随机打乱一个数字序列。
  语法格式:
  y = torch.randperm(n)
  y是把1到n这些数随机打乱得到的一个数字序列。
 
th> torch.randperm(5)
 3
 1
 5
 4
 2
[torch.DoubleTensor of size 5]

                                                                      [0.0003s]
th> torch.randperm(7)
 7
 3
 2
 5
 6
 4
 1
[torch.DoubleTensor of size 7]

 


 
posted @ 2016-12-19 21:41  有梦就要去实现他  阅读(7518)  评论(2编辑  收藏  举报