forked from mindspore-Ecosystem/mindspore
fix sparse api doc
This commit is contained in:
parent
b486abc076
commit
ad2d46cd6f
|
@ -227,6 +227,8 @@ class IndexedSlices:
|
||||||
|
|
||||||
IndexedSlices can only be used in `Cell`'s contruct method.
|
IndexedSlices can only be used in `Cell`'s contruct method.
|
||||||
|
|
||||||
|
Pynative mode not supported at the moment.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
indices (Tensor): A 1-D integer Tensor of shape [D0].
|
indices (Tensor): A 1-D integer Tensor of shape [D0].
|
||||||
values (Tensor): A Tensor of any dtype of shape [D0, D1, ..., Dn].
|
values (Tensor): A Tensor of any dtype of shape [D0, D1, ..., Dn].
|
||||||
|
@ -237,16 +239,17 @@ class IndexedSlices:
|
||||||
IndexedSlices, composed of `indices`, `values`, `dense_shape`.
|
IndexedSlices, composed of `indices`, `values`, `dense_shape`.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
>>> # Create a IndexedSlices.
|
>>> class Net(nn.Cell):
|
||||||
>>> indices = Tensor([1, 2])
|
>>> def __init__(self, dense_shape):
|
||||||
>>> values = Tensor([[0, 0], [1, 2]], dtype=ms.float32)
|
>>> super(Net, self).__init__()
|
||||||
>>> dense_shape = (3, 2)
|
>>> self.dense_shape = dense_shape
|
||||||
>>> indexed_slices = IndexedSlices(indices, values, dense_shape)
|
>>> def construct(self, indices, values):
|
||||||
|
>>> x = IndexedSlices(indices, values, self.dense_shape)
|
||||||
|
>>> return x.values(), x.indices(), x.dense_shape()
|
||||||
>>>
|
>>>
|
||||||
>>> # Get atrr.
|
>>> indices = Tensor([0])
|
||||||
>>> indices = indexed_slices.indices()
|
>>> values = Tensor([[1, 2]], dtype=ms.float32)
|
||||||
>>> values = indexed_slices.values()
|
>>> Net((3, 2))(indices, values)
|
||||||
>>> dense_shape = indexed_slices.dense_shape()
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, indices, values, dense_shape):
|
def __init__(self, indices, values, dense_shape):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
@ -258,6 +261,8 @@ class SparseTensor:
|
||||||
|
|
||||||
SparseTensor can only be used in `Cell`'s contruct method.
|
SparseTensor can only be used in `Cell`'s contruct method.
|
||||||
|
|
||||||
|
Pynative mode not supported at the moment.
|
||||||
|
|
||||||
For a tensor dense, its SparseTensor(indices, values, dense_shape) has
|
For a tensor dense, its SparseTensor(indices, values, dense_shape) has
|
||||||
`dense[indices[i]] = values[i]`.
|
`dense[indices[i]] = values[i]`.
|
||||||
|
|
||||||
|
@ -273,17 +278,18 @@ class SparseTensor:
|
||||||
Returns:
|
Returns:
|
||||||
SparseTensor, composed of `indices`, `values`, `dense_shape`.
|
SparseTensor, composed of `indices`, `values`, `dense_shape`.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
>>> # Create a SparseTensor.
|
>>> class Net(nn.Cell):
|
||||||
|
>>> def __init__(self, dense_shape):
|
||||||
|
>>> super(Net, self).__init__()
|
||||||
|
>>> self.dense_shape = dense_shape
|
||||||
|
>>> def construct(self, indices, values):
|
||||||
|
>>> x = SparseTensor(indices, values, self.dense_shape)
|
||||||
|
>>> return x.values(), x.indices(), x.dense_shape()
|
||||||
|
>>>
|
||||||
>>> indices = Tensor([[0, 1], [1, 2]])
|
>>> indices = Tensor([[0, 1], [1, 2]])
|
||||||
>>> values = Tensor([1, 2], dtype=ms.float32)
|
>>> values = Tensor([1, 2], dtype=ms.float32)
|
||||||
>>> dense_shape = (3, 4)
|
>>> Net((3, 4))(indices, values)
|
||||||
>>> sparse_tensor = SparseTensor(indices, values, dense_shape)
|
|
||||||
>>>
|
|
||||||
>>> # Get atrr.
|
|
||||||
>>> indices = sparse_tensor.indices()
|
|
||||||
>>> values = sparse_tensor.values()
|
|
||||||
>>> dense_shape = sparse_tensor.dense_shape()
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, indices, values, dense_shape):
|
def __init__(self, indices, values, dense_shape):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
Loading…
Reference in New Issue