1mindspore.SparseTensor 2====================== 3 4.. py:class:: mindspore.SparseTensor(indices, values, shape) 5 6 用来表示某一张量在给定索引上非零元素的集合。 7 8 `SparseTensor` 只能在 `Cell` 的构造方法中使用。 9 10 .. note:: 11 此接口从 1.7 版本开始弃用,并计划在将来移除。请使用 :class:`mindspore.COOTensor`。 12 13 对于稠密张量,其 `SparseTensor(indices, values, shape)` 具有 `dense[indices[i]] = values[i]` 。 14 15 参数: 16 - **indices** (Tensor) - shape为 :math:`(N, ndims)` 的二维整数张量,其中N和ndims分别表示稀疏张量中 `values` 的数量和SparseTensor维度的数量。 17 - **values** (Tensor) - shape为 :math:`(N)` 的一维张量,其内部可以为任何数据类型,用来给 `indices` 中的每个元素提供数值。 18 - **shape** (tuple(int)) - shape为 :math:`(ndims)` 的整数元组,用来指定稀疏矩阵的稠密形状。 19 20 返回: 21 SparseTensor,由 `indices` 、 `values` 和 `shape` 组成。 22 23 .. py:method:: indices 24 :property: 25 26 返回SparseTensor的索引值。 27 28 .. py:method:: shape 29 :property: 30 31 返回SparseTensor的稠密shape。 32 33 .. py:method:: values 34 :property: 35 36 返回SparseTensor的非零元素值。 37