評價此頁

torch.Tensor.col_indices#

Tensor.col_indices() IntTensor#

返回當 selfsparse_csr 佈局的稀疏 CSR 張量時,包含 self 張量列索引的張量。 col_indices 張量的形狀嚴格為 (self.nnz()),型別為 int32int64。在使用 MKL 例程(如稀疏矩陣乘法)時,為了避免下溢並且可能丟失資訊,必須使用 int32 索引。

示例

>>> csr = torch.eye(5,5).to_sparse_csr()
>>> csr.col_indices()
tensor([0, 1, 2, 3, 4], dtype=torch.int32)