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