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]。