tf.sparse.from_dense

Converts a dense tensor into a sparse tensor.

Compat aliases for migration

See Migration guide for more details.

tf.compat.v1.sparse.from_dense, `tf.compat.v2.sparse.from_dense`

Only elements not equal to zero will be present in the result. The resulting SparseTensor has the same dtype and shape as the input.

tensor A dense Tensor to be converted to a SparseTensor.
name Optional name for the op.

The SparseTensor.