欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

pytorch索引查找 index_select的例子

 更新時(shí)間:2019年08月18日 19:18:23   作者:ShellCollector  
今天小編就為大家分享一篇pytorch索引查找 index_select的例子,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧

index_select

anchor_w = self.FloatTensor(self.scaled_anchors).index_select(1, self.LongTensor([0]))

參數(shù)說明:index_select(x, 1, indices)

1代表維度1,即列,indices是篩選的索引序號(hào)。

例子:

import torch
 
 
x = torch.linspace(1, 12, steps=12).view(3,4)
 
print(x)
indices = torch.LongTensor([0, 2])
y = torch.index_select(x, 0, indices)
print(y)
 
z = torch.index_select(x, 1, indices)
print(z)
 
z = torch.index_select(y, 1, indices)
print(z)

結(jié)果:

tensor([[ 1.,  2.,  3.,  4.],
    [ 5.,  6.,  7.,  8.],
    [ 9., 10., 11., 12.]])
tensor([[ 1.,  2.,  3.,  4.],
    [ 9., 10., 11., 12.]])
tensor([[ 1.,  3.],
    [ 5.,  7.],
    [ 9., 11.]])
tensor([[ 1.,  3.],
    [ 9., 11.]])

以上這篇pytorch索引查找 index_select的例子就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論