索引与切片(冒号的用法)
indexing
select first/last N
取连续的片段,正向从0,反向从-1。
select by steps
有间隔采样。
select by specific index
给具体的索引号。
a.index_select(0,torch.tensor([0,2]))第一个参数为维度,对第0维也就是照片张数采样,第二个参数为选中的第0张照片和第二张照片(也就是第一张和第三张)。
…
“…”表示任意多的维度,根据实际的shape来推测代表多少维度。
select by mask
torch.masked_select()
select by flatten index
不在特定的维度,take把原矩阵打平。