torch.select¶ torch.select(input, dim, index) → Tensor¶ 沿着给定索引处的选定维度切片 input 张量。此函数返回原始张量的视图,并移除了给定的维度。 注意 如果 input 是稀疏张量,并且无法返回张量的视图,则会引发 RuntimeError 异常。在这种情况下,请考虑使用 torch.select_copy() 函数。 参数 input (Tensor) – 输入张量。 dim (int) – 要切片的维度 index (int) – 要选择的索引 注意 select() 等价于切片。 例如,tensor.select(0, index) 等价于 tensor[index],而 tensor.select(2, index) 等价于 tensor[:,:,index]。