<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/transform/blob/v1.21.0/tensorflow_transform/mappers.py#L185-L220) |

Converts a `SparseTensor` into a dense tensor and sets its shape.

    tft.sparse_tensor_to_dense_with_shape(
        x: tf.SparseTensor,
        shape: Union[tf.TensorShape, Iterable[int]],
        default_value: Union[tf.Tensor, int, float, str] = 0
    ) -> tf.Tensor

### Used in the notebooks

| Used in the tutorials |
|---|
| - [Recommending Movies: Recommender Models in TFX](https://www.tensorflow.org/tfx/tutorials/tfx/recommenders) |

<br />

<br />

<br />

| ## Args ||
|---|---|

<br />

*** ** * ** ***

x: A `SparseTensor`.
shape: The desired shape of the densified `Tensor`.
default_value: (Optional) Value to set for indices not specified. Defaults
to zero.

<br />

<br />

<br />

| ## Returns ||
|---|---|

<br />

*** ** * ** ***

A `Tensor` with the desired shape.

<br />

<br />

<br />

| ## Raises ||
|---|---|

<br />

*** ** * ** ***

ValueError: If input is not a `SparseTensor`.