torch.Tensor.col_indices¶
- Tensor.col_indices() IntTensor¶
當
self是佈局為sparse_csr的稀疏 CSR 張量時,返回包含self張量的列索引的張量。col_indices張量的形狀嚴格為 (self.nnz()),型別為int32或int64。在使用諸如稀疏矩陣乘法等 MKL 例程時,必須使用int32索引,以避免向下轉型並可能丟失資訊。- 示例:
>>> csr = torch.eye(5,5).to_sparse_csr() >>> csr.col_indices() tensor([0, 1, 2, 3, 4], dtype=torch.int32)