torch.Tensor.col_indices¶
- Tensor.col_indices() IntTensor¶
返回包含当
self是布局为sparse_csr的稀疏 CSR 张量时,self张量的列索引的张量。col_indices张量的形状严格为 (self.nnz()),并且类型为int32或int64。 在使用 MKL 例程(如稀疏矩阵乘法)时,必须使用int32索引,以避免向下转换并可能丢失信息。- Example::
>>> csr = torch.eye(5,5).to_sparse_csr() >>> csr.col_indices() 张量([0, 1, 2, 3, 4], dtype=torch.int32)