values

paddle.Tensor. values ( self )
Notes:

This API is ONLY available in Dygraph mode

Get the values of current SparseTensor(COO or CSR).

Returns

A DenseTensor

Return type

Tensor

Examples

>>> import paddle
>>> indices = [[0, 0, 1, 2, 2], [1, 3, 2, 0, 1]]
>>> values = [1, 2, 3, 4, 5]
>>> dense_shape = [3, 4]
>>> sparse_x = paddle.sparse.sparse_coo_tensor(paddle.to_tensor(indices, dtype='int32'), paddle.to_tensor(values, dtype='float32'), shape=dense_shape)
>>> print(sparse_x.values())
Tensor(shape=[5], dtype=float32, place=Place(cpu), stop_gradient=True,
[1., 2., 3., 4., 5.])