tf.sparse.reset_shape

View source on GitHub

Resets the shape of a SparseTensor with indices and values unchanged.

tf.sparse.reset_shape(
    sp_input, new_shape=None
)

If new_shape is None, returns a copy of sp_input with its shape reset to the tight bounding box of sp_input. This will be a shape consisting of all zeros if sp_input has no values.

If new_shape is provided, then it must be larger or equal in all dimensions compared to the shape of sp_input. When this condition is met, the returned SparseTensor will have its shape reset to new_shape and its indices and values unchanged from that of sp_input.

For example:

Consider a sp_input with shape [2, 3, 5]:

Args:

Returns:

A SparseTensor indices and values unchanged from input_sp. Its shape is new_shape if that is set. Otherwise it is the tight bounding box of input_sp

Raises: