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