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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[],null,["# tf.sparse.to_dense\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/sparse_ops.py#L1681-L1734) |\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\n### Used in the notebooks\n\n| Used in the guide | Used in the tutorials |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| - [Working with sparse tensors](https://www.tensorflow.org/guide/sparse_tensor) - [Migrate \\`tf.feature_column\\`s to Keras preprocessing layers](https://www.tensorflow.org/guide/migrate/migrating_feature_columns) - [Ragged tensors](https://www.tensorflow.org/guide/ragged_tensor) - [Introduction to Tensors](https://www.tensorflow.org/guide/tensor) - [Introduction to tensor slicing](https://www.tensorflow.org/guide/tensor_slicing) | - [Graph-based Neural Structured Learning in TFX](https://www.tensorflow.org/tfx/tutorials/tfx/neural_structured_learning) - [Text generation with an RNN](https://www.tensorflow.org/text/tutorials/text_generation) - [TFX Estimator Component Tutorial](https://www.tensorflow.org/tfx/tutorials/tfx/components) - [TFX Keras Component Tutorial](https://www.tensorflow.org/tfx/tutorials/tfx/components_keras) |\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"]]