快捷方式

torch.Tensor.crow_indices

Tensor.crow_indices() IntTensor

self 是一个布局为 sparse_csr 的稀疏 CSR tensor 时,返回包含 self tensor 压缩行索引的 tensor。crow_indices tensor 的形状严格为 (self.size(0) + 1),类型为 int32int64。当使用 MKL 例程(例如稀疏矩阵乘法)时,需要使用 int32 索引,以避免向下转型并可能丢失信息。

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

文档

查阅 PyTorch 的全面开发者文档

查看文档

教程

获取针对初学者和高级开发者的深度教程

查看教程

资源

查找开发资源并获得疑问解答

查看资源