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_shape and values specified by
the non-empty values in sp_input. Indices not in sp_input are assigned
default_value.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tf.sparse.to_dense\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/ops/sparse_ops.py#L1679-L1732) |\n\nConverts a `SparseTensor` into a dense tensor.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.sparse.to_dense`](https://www.tensorflow.org/api_docs/python/tf/sparse/to_dense), [`tf.compat.v1.sparse_tensor_to_dense`](https://www.tensorflow.org/api_docs/python/tf/sparse/to_dense)\n\n\u003cbr /\u003e\n\n tf.sparse.to_dense(\n sp_input, default_value=None, validate_indices=True, name=None\n )\n\nFor this sparse tensor with three non-empty values: \n\n sp_input = tf.sparse.SparseTensor(\n dense_shape=[3, 5],\n values=[7, 8, 9],\n indices =[[0, 1],\n [0, 3],\n [2, 0]])\n\nThe output will be a dense `[3, 5]` tensor with values: \n\n tf.sparse.to_dense(sp_input).numpy()\n array([[0, 7, 0, 8, 0],\n [0, 0, 0, 0, 0],\n [9, 0, 0, 0, 0]], dtype=int32)\n\n| **Note:** Indices must be without repeats. This is only tested if `validate_indices` is `True`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------------|------------------------------------------------------------------------------------------------------------------------------------|\n| `sp_input` | The input `SparseTensor`. |\n| `default_value` | Scalar value to set for indices not specified in `sp_input`. Defaults to zero. |\n| `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. |\n| `name` | A name prefix for the returned tensors (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A dense tensor with shape `sp_input.dense_shape` and values specified by the non-empty values in `sp_input`. Indices not in `sp_input` are assigned `default_value`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-------------|----------------------------------------|\n| `TypeError` | If `sp_input` is not a `SparseTensor`. |\n\n\u003cbr /\u003e"]]