| View source on GitHub | 
Converts a SparseTensor into a dense tensor.
tf.sparse.to_dense(
    sp_input, default_value=None, validate_indices=True, name=None
)
  For this sparse tensor with three non-empty values:
sp_input = tf.SparseTensor(
  dense_shape=[3, 5],
  values=[7, 8, 9],
  indices =[[0, 1],
            [0, 3],
            [2, 0]])
 The output will be a dense [3, 5] tensor with values:
tf.sparse.to_dense(sp_input).numpy()
array([[0, 7, 0, 8, 0],
       [0, 0, 0, 0, 0],
       [9, 0, 0, 0, 0]], dtype=int32)
 Note: Indices must be without repeats. This is only tested ifvalidate_indicesisTrue.
| Args | |
|---|---|
| sp_input | The input SparseTensor. | 
| default_value | Scalar value to set for indices not specified in sp_input. Defaults to zero. | 
| validate_indices | A boolean value. If True, indices are checked to make sure they are sorted in lexicographic order and that there are no repeats. | 
| name | A name prefix for the returned tensors (optional). | 
| Returns | |
|---|---|
| A dense tensor with shape sp_input.dense_shapeand values specified by the non-empty values insp_input. Indices not insp_inputare assigneddefault_value. | 
| Raises | |
|---|---|
| TypeError | If sp_inputis not aSparseTensor. | 
    © 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
    https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/sparse/to_dense