<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/probability/blob/v0.25.0/tensorflow_probability/python/math/sparse.py#L27-L58) |

Converts dense `Tensor` to `SparseTensor`, dropping `ignore_value` cells.

    tfp.math.dense_to_sparse(
        x, ignore_value=None, name=None
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x` | A `Tensor`. |
| `ignore_value` | Entries in `x` equal to this value will be absent from the return `SparseTensor`. If `None`, default value of `x` dtype will be used (e.g. '' for `str`, 0 for `int`). |
| `name` | Python `str` prefix for ops created by this function. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| `sparse_x` | A [`tf.SparseTensor`](https://www.tensorflow.org/api_docs/python/tf/sparse/SparseTensor) with the same shape as `x`. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | when `x`'s rank is `None`. |

<br />