tf.ragged.constant

View source on GitHub

Constructs a constant RaggedTensor from a nested Python list.

tf.ragged.constant(
    pylist, dtype=None, ragged_rank=None, inner_shape=None, name=None,
    row_splits_dtype=tf.dtypes.int64
)

Example:

>>> tf.ragged.constant([[1, 2], [3], [4, 5, 6]])
<tf.RaggedTensor [[1, 2], [3], [4, 5, 6]]>

All scalar values in pylist must have the same nesting depth K, and the returned RaggedTensor will have rank K. If pylist contains no scalar values, then K is one greater than the maximum depth of empty lists in pylist. All scalar values in pylist must be compatible with dtype.

Args:

Returns:

A potentially ragged tensor with rank K and the specified ragged_rank, containing the values from pylist.

Raises: